`nix shell` packages should shadow existing packages, right?

⮞ node --version
v16.15.0

⮞ file (which node)
/home/james/.nix-profile/bin/node: symbolic link to /nix/store/nyvl94ibcdzvkkz99s44skfyxh4mdkc5-home-manager-path/bin/node

⮞ nix shell nixpkgs#nodejs-18_x

⮞ node --version
v16.15.0

⮞ file (which node)
/home/james/.nix-profile/bin/node: symbolic link to /nix/store/nyvl94ibcdzvkkz99s44skfyxh4mdkc5-home-manager-path/bin/node

I would expect nodejs 18 to be available inside the nix shell, shadowing the one I installed with home-manager. Is that what should happen? Why is it not?
Could this be related to the fact that I’m using fish?

2 Likes

Please echo $PATH for both cases.

1 Like

Note that 16 and 18 will now be reversed, as I’ve since installed 18 with home-manager, and am now using nix shell to get 16.

⮞ node --version
v18.7.0

⮞ file (which node)
/home/james/.nix-profile/bin/node: symbolic link to /nix/store/4bf0yidjk19fw5ys0lh38mshvqv9g0af-home-manager-path/bin/node

⮞ echo $PATH
/home/james/.nix-profile/bin /home/james/.pack/bin /home/james/.poetry/bin /home/james/.npm-global/bin /home/james/.nix-profile/bin /home/james/.nix-profile/bin /home/james/.local/bin /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/lib/jvm/default/bin /usr/bin/site_perl /usr/bin/vendor_perl /usr/bin/core_perl /var/lib/snapd/snap/bin /home/james/.cabal/bin /home/james/.ghcup/bin

⮞ nix shell nixpkgs#nodejs-16_x

⮞ file (which node)
/home/james/.nix-profile/bin/node: symbolic link to /nix/store/4bf0yidjk19fw5ys0lh38mshvqv9g0af-home-manager-path/bin/node

⮞ echo $PATH
/home/james/.nix-profile/bin /home/james/.pack/bin /home/james/.poetry/bin /home/james/.npm-global/bin /nix/store/s6isdp5wxcz0hfcj72wfb9wvpkkh7ppg-nodejs-16.16.0/bin /home/james/.nix-profile/bin /home/james/.nix-profile/bin /home/james/.nix-profile/bin /home/james/.local/bin /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/lib/jvm/default/bin /usr/bin/site_perl /usr/bin/vendor_perl /usr/bin/core_perl /var/lib/snapd/snap/bin /home/james/.cabal/bin /home/james/.ghcup/bin

Could this be caused by https://github.com/lilyball/nix-env.fish, which I’m installing with home-manager?

Possibly. At least something (apparently unrelated) is prepending stuff to your $PATH on shell initialization.

1 Like
Hosted by Flying Circus.