nix-env and nix-build not found after installation (debian buster)

Viewed 7051

after the installation following the instructions with

curl https://nixos.org/nix/install | sh

and logout/login, nix-env and nix-build are not found. I had the problem with debian stretch and now with buster. What am I doing wrong?

3 Answers

The nix manual instructs to execute

source ~/.nix-profile/etc/profile.d/nix.sh

but the instructions printed after the execution say to do (I do not remember exactly)

./~/.nix-profile/etc/profile.d/nix.sh

and the same command is inserted into ~/.profile. The cause of the problem is the difference between . and source (see https://superuser.com/questions/46139/what-does-source-do). The script is setting up the $PATH variable in the environment and has the desired effect wtih source but no effect with . (which operates in its own shell and closes it at the end).

Cure: change the line in .profile (or better move it to .bashrc) to

if [ -e /home/xxx/.nix-profile/etc/profile.d/nix.sh ]; then source /home/xxx/.nix-profile/etc/profile.d/nix.sh; fi

(xxx is your user name),

For me only setting $PATH like this worked (in .profile)

export PATH="$PATH:/nix/var/nix/profiles/default/bin"
Related