Home-manager manages zsh but does not include nix-profile in path

So in my home manger config I have enabled zsh and I can confirm that in general the home-manager config is working (home-manager switch reacts to changes in the home.nix, etc.)

programs.direnv.enable = true;
programs.zsh.enable = true;

programs.zsh = {
  shellAliases = {
    ll = "ls -l";
    update = "nix-channel --update && home-manager switch";
  };
  profileExtra = ''
EDITOR='emacs'
VISUAL='emacs'
.......

However, applications like home-manager are not in path. I can set PATH manually, and then these applications are found

% whereis emacs
emacs: /usr/bin/emacs /usr/lib/emacs /etc/emacs /usr/share/emacs /usr/share/man/man1/emacs.1.gz /usr/share/info/emacs
% whereis home-manager
home-manager:
% export PATH=$PATH:$HOME/.nix-profile/bin/
% whereis home-manager                     
home-manager: /nix/store/n46nnlf4nynnycyqxdp1605c8y6pzs6j-user-environment/bin/home-manager

I do believe however they should be automatically set (?)

Overall it seems that .zshrcis generated and contains for example the aliases defined in home.nix and the direnv config.

% cat ~/.zshenv                                                                                                                        
# Environment variables
. "/home/USER/.nix-profile/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

Btw. PATH currently contains

% echo $PATH                                                                                                                           
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

and

 % echo $__HM_ZSH_SESS_VARS_SOURCED 
1

indicating that the ~/.zshenv was sourced.

1 Like

Have you tried enabling generic linux support (targets.genericLinux.enable)?

It should automatically source nix.sh at startup, which sets the correct PATH and other such things.