arrterian / nix-env-selector

Allows switch environment for Visual Studio Code using Nix Package Manager.
MIT License
221 stars 28 forks source link

Exec nix-shell using working directory of nix-config #54

Closed shayne closed 3 years ago

shayne commented 3 years ago
Status Type Config Change
Ready Feature/Bug No

Problem

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.

arrterian commented 3 years ago

Merged & released. Thanks for your contribution @shayne .