fzf.defaultOptions not applied in home-manager

Running a clean install of NixOS in a vm and am learning my way around. I’ve installed the home-manager module and am attempting to configure fzf but setting defaultOptions isn’t working (fzf is working though). As I’m new to NixOS I’m doing this in configuration.nix. These options work if I place them in .zshrc.

 # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.me = {
    isNormalUser = true;
    description = "me";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
    #  thunderbird
    ];
  };

  #### HOME MANAGER #### 
  home-manager.users.me = { pkgs, ... }: {
    home.stateVersion = "24.11";  
    home.packages = with pkgs; [btop];
    programs.fzf = {
      enable = true;
      enableZshIntegration = true;
      defaultOptions = [
        "layout=reverse"
        "info=inline"
        "preview='bat {}'"
        "border=rounded"
        "margin=1"
        "padding=1" 
      ];
    };
  };

The way you set the default option is wrong, see the example from Home Manager - Option Search shows that you should be setting is options as command line argument:

[
  "--height 40%"
  "--border"
]

this is equivalent to

fzf --height 40 --border

Change your option to

      defaultOptions = [
        "--layout=reverse"
        "--info=inline"
        "--preview='bat {}'"
        "--border=rounded"
        "--margin=1"
        "--padding=1" 
      ];

I’ve seen examples with and without the leading dashes, however, neither work in the home-manager defaultOptions config.

It does work on my machine, did you restart your desktop environment or reboot? As home manager will only apply the change after you restart you user session.

You should be seeing the FZF_DEFAULT_OPTS environment variable being set, if it is not set then try restart your user session.

Yes, I logout and in after each build. I’ve also tried adding via sessionVariables in home manager and that doesn’t work either. When i echo $FZF_DEFAULT_OPTS nothing returns.

programs.zsh = {    
       sessionVariables = {
        FZF_DEFAULT_OPTS = "--layout=reverse --info=inline --preview='bat {}' --border=rounded --margin=1 --padding=1";
       };

Is all of your config in configuration.nix or do you have a separate home.nix file for home manager? I’m setting everything in configuration.nix as this is a single user system.

My setup is broken into multiple modules using flake.

The home manager part is:

  programs.git = {
    enable = true;
    userName = "user";
    userEmail = "user@email.com";
  };

  programs.bash = {

    enable = true;
    bashrcExtra = ''
    '';
  };

  xdg = {
    enable = true;
    userDirs.createDirectories = true;
    userDirs.enable = true;
  };

  home.packages = with pkgs; [
  ];

   programs.fzf = {
      enable = true;
      enableZshIntegration = true;
      enableBashIntegration = true;
      defaultOptions = [
        "--info=inline"
        "--border=rounded"
        "--margin=1"
        "--padding=1" 
      ];
   };

Maybe you didn’t enable zsh in your home manager config? Because you will also need that to make home manager manage your shell. If that doesn’t work, try to enable bash.

Try add this:

home-manager.users.me = { pkgs, ... }: {
// other config
programs.zsh.enable = true;
programs.bash.enable = true;
};

Do you have home-manager.users.me.programs.zsh.enable = true? Without that, all the ZSH related things in HM are noops.

I had enabled zsh in home manager previously but on rebuild it would fail. I suspect manually editing my .zshrc file with my fzf variables prevented the file from being rewritten during the build process and created a conflict. Manually deleting my .zshrc file and enabling zsh in home manager resolved my issue.

Thank you both for the help :pray: