BTW the “better option” here is nix run
. nix-shell -p foo
sets up the environment as it would for building foo
, so all of foo
’s dependencies are in your PATH
and all of the other environment vars are set too (I count 23 env vars containing NIX
), but nix run
produces an environment much more similar to what you’d get if you simply installed the package (e.g. it basically just prefixes your PATH
with the appropriate directories from the specified package).
That said, nix-shell
replaces your normal shell initialization files and nix run
doesn’t, so depending on how your .bashrc
is set up you might override the PATH
. For example with my setup, echo $PATH
in a nix run
shell starts the path with /usr/local/bin
before the nix-provided path value, because my current .bashrc
unconditionally prefixes my PATH (which I really should fix).