The nix-shell is commonly run from within the directory containing the shell.nix/default.nix, implicitly setting the working directory to that which contains the nix file.
nix-env-selector calls exec/execSync without a working directory set. Thus the working directory is "/".
In the event that the nix file contains references to $PWD, not uncommon to see in a shellHook, the user will see different behavior from running nix-shell from the terminal vs the extension running it to extract the environment.
Solution
Uses the path#dirname of the :nix-config as the cwd option for the exec and execSync calls.
Problem
The
nix-shell
is commonly run from within the directory containing theshell.nix
/default.nix
, implicitly setting the working directory to that which contains thenix
file.nix-env-selector calls
exec
/execSync
without a working directory set. Thus the working directory is "/
".In the event that the
nix
file contains references to$PWD
, not uncommon to see in ashellHook
, the user will see different behavior from runningnix-shell
from the terminal vs the extension running it to extract the environment.Solution
Uses the
path#dirname
of the:nix-config
as thecwd
option for theexec
andexecSync
calls.