Hey,
I’m trying to run older version of nix but it somehow goes to the bottom of my $PATH.
What could be the reason?
$ nix shell github:nixos/nix/2.11.0
$ nix --version
$ echo $PATH
/nix/var/nix/profiles/default/bin /run/current-system/sw/bin /Users/onnimonni/.nix-profile/bin /nix/store/lr32i0bdarx1iqsch4sy24jj1jkfw9vf-nix-2.11.0/bin /nix/var/nix/profiles/default/bin /Users/onnimonni/.nix-profile/bin /usr/local/bin /System/Cryptexes/App/usr/bin /usr/bin /bin /usr/sbin /sbin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin /Library/Apple/usr/bin
So it indeed adds the /nix/store/lr32i0bdarx1iqsch4sy24jj1jkfw9vf-nix-2.11.0/bin
to the $PATH but it’s below /nix/var/nix/profiles/default/bin
and /run/current-system/sw/bin
so it will never be used.
I installed my nix initially from NixOS installer:
curl -L https://nixos.org/nix/install | sh -s
And I’m using nix-darwin
with my flake.nix visible here.
How could I setup my environment in a way where the nix shell
would actually prepend the path to correct place in the $PATH?
1 Like
I’m using fish shell and in it uses space instead of “:”.
I will remove any mentions of these from my shell files but I think the /nix/var/nix/profiles/default wasn’t even mentioned there.
I checked the code for nix daemon and it seems to add that path into the front of the PATH.
I’ve just noticed the same, when trying to use an old version of an already installed package. It was still using the current version instead of the older one.
Could it be an issue with macOS?
For me it only happens in zsh or fish, but not with bash.
I tested it like this:
export SHELL=/bin/bash
bash
echo $PATH
nix shell nixpkgs#hello
echo $PATH # has store path to `hello` at the front
I’m not using nix-darwin therefore I need to source the nix-daemon.sh
script for fish on my own.
I found this GitHub - lilyball/nix-env.fish: Nix environment setup for the fish shell which seems to have the same issue.
How are you sourcing the nix-daemon.sh
script for fish @onnimonni?
Hey,
I hope this helps.
$ ls -lah (which fish)
lrwxr-xr-x 1 root wheel 63B 1 Tam 1970 /run/current-system/sw/bin/fish@ -> /nix/store/2hq38y4h3793c1x686z2vv4fvjmp4wc1-fish-3.7.1/bin/fish
And you can see my fish configs in my dot files: dotfiles/config/fish at main · onnimonni/dotfiles · GitHub
I’m not sourcing the nix-daemon.sh
at all. Should I?
and I used the determinate installer for nix:
$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
Tbh I don’t know anymore, but without the nix-env.fish
script my path was not populated with my nix profile. Now on a standalone installation of nix on linux I didn’t need to do it.
So it’s either a macOS thing or nix had no integration for fish at the point where I’ve installed it 