Fzf home-manager module ineffective

programs.fzf.colors = {
    colors = {
      "bg+" = "#${theme.base02}";
      bg = "#${theme.base00}";
      spinner = "#${theme.base09}";
      hl = "#${theme.base0A}";
      fg = "#${theme.base04}";
      header = "#${theme.base0B}";
      gutter = "#${theme.base00}";
      info = "#${theme.base0C}";
      pointer = "#${theme.base0D}";
      marker = "#${theme.base08}";
      "fg+" = "#${theme.base05}";
      prompt = "#${theme.base04}";
      "hl+" = "#${theme.base0A}";
      border = "#403d52"; # Rose-pine color
    };

};

Has no effect on the fzf colors. How do I get it working?

Are you setting programs.fzf.enable?

Yep.

This is the whole configuration with nix-colors:

{ config, ... }:
let
  theme = config.colorScheme.palette;
in
{
  programs.fzf = {
    enable = true;
    enableZshIntegration = true;

    colors = {
      "bg+" = "#${theme.base02}";
      bg = "#${theme.base00}";
      spinner = "#${theme.base09}";
      hl = "#${theme.base0A}";
      fg = "#${theme.base04}";
      header = "#${theme.base0B}";
      gutter = "#${theme.base00}";
      info = "#${theme.base0C}";
      pointer = "#${theme.base0D}";
      marker = "#${theme.base08}";
      "fg+" = "#${theme.base05}";
      prompt = "#${theme.base04}";
      "hl+" = "#${theme.base0A}";
      border = "#403d52"; # Rose-pine color
    };
  };
}

From what I remember as part of the last time I configured fzf using home-manger(although I mostly cared about the CTR-T/R and default command). I had to log in and out as a user for the changes to take effect).

Well, I am reporting about this very late. I have rebooted my system several times. Isn’t there a way to check the logs or something like that? To see what the real FZF_DEFAULT_OPTS is? I do echo $FZF_DEFAULT_OPTS and nothing shows up.

I am not sure why you don"t see the values in the shell when I do

printenv | grep FZF

I am getting

FZF_ALT_C_COMMAND=fd --type directory --hidden --exclude .git
FZF_CTRL_T_COMMAND=fd --type file --type directory --hidden --exclude .git
FZF_DEFAULT_COMMAND=fd --type file --hidden --exclude .git

which are the values I set inside my config file

{ ... }:

{

  programs.fzf = {
    enable = true;
    enableZshIntegration = true;
    enableBashIntegration = true;

    # Note: Effect to the shell environment variables only took place after reboot.

    # rg can be used but fd is the better choice. It is purpose built for listing files,
    # which is what you want for fzf. ripgrep can list files too, but that
    # isn't its primary function. Its primary function is to search files.

    # CTRL-T - $FZF_CTRL_T_COMMAND
    fileWidgetCommand = ''fd --type file --type directory --hidden --exclude .git'';

    # ALT-C - $FZF_ALT_C_COMMAND
    changeDirWidgetCommand = "fd --type directory --hidden --exclude .git";

    # Default command that is executed for fzf - $FZF_DEFAULT_COMMAND
    defaultCommand = "fd --type file --hidden --exclude .git";
  };

}

You can also search /nix for the generated files

rg "FZF_CTRL_T_COMMAND" /nix/store

I wrote

$ printenv | grep FZA

And saw nothing. I am on 25.11 xantusia. Here’s my config. The modules/user/shell directory has the shell tool configuration. I don’t have any idea how to fix it. But if it’s working for you, then probably it’s my mistake somewhere. Or perhaps there’s something wrong with the colors module of fzf.
One of two the things.

There is a small typo in your command you should be looking for

printenv | grep FZF

and not

printenv | grep FZA

I also not sure how the colors are set, meaning they are not part of the FZF_* variables. You probably should look at /nix/store you can try:

so look for

rg "#403d52" /nix/store

It was a cpu intensive thing. But I didn’t get anything out of
$ printenv | grep FZF or the rg "#403d52" /nix/store commands.

I am not using nix-colors.url in my flake.nix but I hard coded some values for the colors inside of my VM running nixos.

{ ... }:

let
  theme = {
    base00 = "191724";
    base01 = "1f1d2e";
    base02 = "26233a";
    base03 = "555169";
    base04 = "6e6a86";
    base05 = "e0def4";
    base08 = "eb6f92";
    base09 = "f6c177";
    base0A = "ea9a97";
    base0B = "3e8fb0";
    base0C = "9ccfd8";
    base0D = "c4a7e7";
  };

  # Your custom colors definition

in
{

  programs.fzf = {
    enable = true;
    enableZshIntegration = true;
    enableBashIntegration = true;

    # Note: Effect to the shell environment variables only took place after reboot.

    # rg can be used but fd is the better choice. It is purpose built for listing files,
    # which is what you want for fzf. ripgrep can list files too, but that
    # isn't its primary function. Its primary function is to search files.

    # CTRL-T - $FZF_CTRL_T_COMMAND
    fileWidgetCommand = ''fd --type file --type directory --hidden --exclude .git'';

    # ALT-C - $FZF_ALT_C_COMMAND
    changeDirWidgetCommand = "fd --type directory --hidden --exclude .git";

    # Default command that is executed for fzf - $FZF_DEFAULT_COMMAND
    defaultCommand = "fd --type file --hidden --exclude .git";

    colors = {
      "bg+" = "#${theme.base02}";
      bg = "#${theme.base00}";
      spinner = "#${theme.base09}";
      hl = "#${theme.base0A}";
      fg = "#${theme.base04}";
      header = "#${theme.base0B}";
      gutter = "#${theme.base00}";
      info = "#${theme.base0C}";
      pointer = "#${theme.base0D}";
      marker = "#${theme.base08}";
      "fg+" = "#${theme.base05}";
      prompt = "#${theme.base04}";
      "hl+" = "#${theme.base0A}";
      border = "#403d52"; # Rose-pine color
    };
  };

}

and once I rebuild I can confirm:

  1. colors worked for me.
  2. I was able to find a new FZF variable called FZF_DEFAULT_OPTS with all the colors
printenv | grep FZF
FZF_ALT_C_COMMAND=fd --type directory --hidden --exclude .git
FZF_CTRL_T_COMMAND=fd --type file --type directory --hidden --exclude .git
FZF_DEFAULT_COMMAND=fd --type file --hidden --exclude .git
FZF_DEFAULT_OPTS=--color bg:#191724,bg+:#26233a,border:#403d52,fg:#6e6a86,fg+:#e0def4,gutter:#191724,header:#3e8fb0,hl:#ea9a97,hl+:#ea9a97,info:#9ccfd8,marker:#eb6f92,pointer:#c4a7e7,prompt:#6e6a86,spinner:#f6c177

and was able to find the values I set inside of my /nix/store

rg "#403d52" /nix/store

Are you sure your fzf home-manger configuration are being built? here is my fzf config(without the colors) you can look at how it is included in my repository and might get a clue.

1 Like

this could be your issue Home Manager Manual

1 Like

Okay. I read the files and stuff. I mean I read the .zshenv created by home-manager and the .zshrc created by home manager.

My .zshenv contains this:

. "/etc/profiles/per-user/krish/etc/profile.d/hm-session-vars.sh"

# Only source this once
if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then
  export __HM_ZSH_SESS_VARS_SOURCED=1
  
fi

export ZDOTDIR=$HOME/.config/zsh

And the hm-session-vars.sh contains this:

# Only source this once.
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
export __HM_SESS_VARS_SOURCED=1

export EDITOR="myHomeModuleNvim"
export FZF_ALT_C_COMMAND="fd --type directory --hidden --exclude .git"
export FZF_CTRL_T_COMMAND="fd --type file --type directory --hidden --exclude .git"
export FZF_DEFAULT_COMMAND="fd --type file --hidden --exclude .git"
export FZF_DEFAULT_OPTS="--height 40% --border --color bg:#191724,bg+:#26233a,border:#403d52,fg:#908caa,fg+:#e0def4,gutter:#191724,header:#31748f,hl:#ebbcba,hl+:#ebbcba,info:#9ccfd8,marker:#eb6f92,pointer:#c4a7e7,prompt:#908caa,spinner:#f6c177"
export GTK2_RC_FILES="/home/krish/.gtkrc-2.0"
export LOCALE_ARCHIVE_2_27="/nix/store/nwfcnk783jjdj8w2y5nbqyjkxh2ssjq9-glibc-locales-2.40-66/lib/locale/locale-archive"
export MOZ_ENABLE_WAYLAND="1"
export NIX_XDG_DESKTOP_PORTAL_DIR="/etc/profiles/per-user/krish/share/xdg-desktop-portal/portals"
export QT_QPA_PLATFORMTHEME="gtk2"
export SUDO_PROMPT="$(tput setaf 1 bold)󰌾 $(tput sgr0)$(tput setaf 2) password$(tput sgr0)$(tput setaf 4) for$(tput sgr0)$(tput setaf 5) %p$(tput sgr0)$(tput setaf 3):"
export XCURSOR_SIZE="24"
export XCURSOR_THEME="rose-pine-hyprcursor"
export XDG_CACHE_HOME="/home/krish/.cache"
export XDG_CONFIG_DIRS="/etc/xdg${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}"
export XDG_CONFIG_HOME="/home/krish/.config"
export XDG_DATA_DIRS="/usr/share:/usr/local/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
export XDG_DATA_HOME="/home/krish/.local/share"
export XDG_DESKTOP_DIR="/home/krish/Desktop"
export XDG_DOCUMENTS_DIR="/home/krish/Documents"
export XDG_DOWNLOAD_DIR="/home/krish/Downloads"
export XDG_MUSIC_DIR="/home/krish/Music"
export XDG_PICTURES_DIR="/home/krish/Pictures"
export XDG_PUBLICSHARE_DIR="/home/krish/Public"
export XDG_STATE_HOME="/home/krish/.local/state"
export XDG_TEMPLATES_DIR="/home/krish/Templates"
export XDG_VIDEOS_DIR="/home/krish/Videos"
export QML2_IMPORT_PATH="/etc/profiles/per-user/krish/lib/qt-5.15.16/qml:/etc/profiles/per-user/krish/lib/qt-6/qml${QML2_IMPORT_PATH:+:}$QML2_IMPORT_PATH"
export QT_PLUGIN_PATH="/etc/profiles/per-user/krish/lib/qt-5.15.16/plugins:/etc/profiles/per-user/krish/lib/qt-6/plugins${QT_PLUGIN_PATH:+:}$QT_PLUGIN_PATH"
export XCURSOR_PATH="/etc/profiles/per-user/krish/share/icons${XCURSOR_PATH:+:}$XCURSOR_PATH"

The .zshrc contains this:

lg()
{
    export LAZYGIT_NEW_DIR_FILE=~/.lazygit/newdir

    lazygit "$@"

    if [ -f $LAZYGIT_NEW_DIR_FILE ]; then
            cd "$(cat $LAZYGIT_NEW_DIR_FILE)"
            rm -f $LAZYGIT_NEW_DIR_FILE > /dev/null
    fi
}


typeset -U path cdpath fpath manpath
for profile in ${(z)NIX_PROFILES}; do
  fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
done

HELPDIR="/nix/store/4kaqyfdyq0mj70r3q8ms2zyahdz7zggp-zsh-5.9/share/zsh/$ZSH_VERSION/help"

path+="$HOME/.config/zsh/plugins/fzf-tab"
fpath+="$HOME/.config/zsh/plugins/fzf-tab"


autoload -U compinit && compinit
source /nix/store/81s1mpv0x9r9p18xsp68h2083aipkmvq-zsh-autosuggestions-0.7.1/share/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_STRATEGY=(completion)


if [[ -f "$HOME/.config/zsh/plugins/fzf-tab/fzf-tab.plugin.zsh" ]]; then
  source "$HOME/.config/zsh/plugins/fzf-tab/fzf-tab.plugin.zsh"
fi
# History options should be set in .zshrc and after oh-my-zsh sourcing.
# See https://github.com/nix-community/home-manager/issues/177.
HISTSIZE="10000"
SAVEHIST="10000"

HISTFILE="$HOME/.zsh_history"
mkdir -p "$(dirname "$HISTFILE")"

setopt HIST_FCNTL_LOCK
unsetopt APPEND_HISTORY
setopt HIST_IGNORE_DUPS
unsetopt HIST_IGNORE_ALL_DUPS
unsetopt HIST_SAVE_NO_DUPS
unsetopt HIST_FIND_NO_DUPS
setopt HIST_IGNORE_SPACE
unsetopt HIST_EXPIRE_DUPS_FIRST
setopt SHARE_HISTORY
unsetopt EXTENDED_HISTORY


if [[ $options[zle] = on ]]; then
  source <(/nix/store/z3ayhjslz72ldiwrv3mn5n7rs96p2g8a-fzf-0.62.0/bin/fzf --zsh)
fi

function y() {
  local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
  yazi "$@" --cwd-file="$tmp"
  if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
    builtin cd -- "$cwd"
  fi
  rm -f -- "$tmp"
}

if [[ $TERM != "dumb" ]]; then
  eval "$(/nix/store/sa6y5dghbdj04i4dwz7lxglfk1iafdci-starship-1.23.0/bin/starship init zsh)"
fi

if test -n "$KITTY_INSTALLATION_DIR"; then
  export KITTY_SHELL_INTEGRATION="no-rc"
  autoload -Uz -- "$KITTY_INSTALLATION_DIR"/shell-integration/zsh/kitty-integration
  kitty-integration
  unfunction kitty-integration
fi

alias -- ..='cd ..'
alias -- btop='btop --force-utf'
alias -- cdg='cd $(git rev-parse --show-toplevel)'
alias -- cleanall='sudo nix-collect-garbage -d && nix-collect-garbage -d'
alias -- eza='eza --icons auto --color auto --git --group-directories-first --header'
alias -- ffetch=/nix/store/jwlbs8ifkmdll51mkv3xq0b5cbg83pra-fastfetch-2.45.0/bin/fastfetch
alias -- gocon='cd $HOME/.dotfiles'
alias -- kitcat='/nix/store/xr89vplyhipa0gmxnf08pj2jrlxkw864-kitty-0.42.1/bin/kitten icat'
alias -- la='eza -a'
alias -- ll='eza -l'
alias -- lla='eza -la'
alias -- ls=eza
alias -- lt='eza --tree'
alias -- oldvim=/nix/store/i5323bb72x07y56d8z2iwb589g56k2y8-vim-9.1.1336/bin/vim
alias -- peaclock='/nix/store/ii2q1w8n1dsdzvf9v5vhfjd6g26f2ywp-peaclock-0.4.3/bin/peaclock --config-dir ~/.config/peaclock --config ~/.config/peaclock/config'
alias -- rm='echo "Don'\''t use this, use trash";false'
alias -- update='sudo nixos-rebuild switch'
alias -- yt-music='yt-dlp -x -f bestaudio'
source /nix/store/rjrc4zzpjn9viahdjikggpqa6436jnwq-zsh-syntax-highlighting-0.8.0/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS+=()



eval "$(/nix/store/lgq3wvj0rnds3nmisx0x4s622sgj42vg-zoxide-0.9.8/bin/zoxide init zsh --cmd cd)"

Notice that the hm-session-vars.sh does contain the FZF* vars, but still they don’t show up in the printenv command.

Okay something happened after I copied the lines from your original config (the one without the colors). the FZF_DEFAULT_OPTS began to be sourced. I don’t know what’s actually happening here. I also gave a defaultOptions = ; line.

1 Like

I am using the home-manager as nixos module. After every nixos-rebuild switch, the .nix-profile in the home-directory is a broken symlink. The hm-session-vars are all sourced in the .zshenv, so this is not required. But I do remember on older versions on nixos (24.11 and less), the home-manager session variables were not sourced.