Describe the bug
When using nix-shell in a shebang, it interprets filenames given to it relative to the script dir, but it interprets the -E flag relative to the cwd. This is rather problematic. I can't think of any reason to want the -E flag interpreted relative to the current dir and doing so means I'm forced to write a deps.nix file to disk next to my script if I need to import some other file at a known path.
More generally, I should be able to replace #!nix-shell deps.nix -i bash with #!nix-shell -E 'import ./deps.nix' -i bash.
Steps To Reproduce
Write a script that looks something like
#!/usr/bin/env nix-shell
#!nix-shell -i bash -E "with import ./deps.nix {}; mkShell { buildInputs = [bash]; }"
echo it works
Expected behavior
It shouldn't matter what my cwd is when I execute this, it should behave the same and import the deps.nix file that lives right next to the script.
Actual behavior
It tries to import ./deps.nix from whatever my cwd is.
nix-env --version output
nix-env (Nix) 2.3.7
Describe the bug
When using
nix-shellin a shebang, it interprets filenames given to it relative to the script dir, but it interprets the-Eflag relative to the cwd. This is rather problematic. I can't think of any reason to want the-Eflag interpreted relative to the current dir and doing so means I'm forced to write a deps.nix file to disk next to my script if I need to import some other file at a known path.More generally, I should be able to replace
#!nix-shell deps.nix -i bashwith#!nix-shell -E 'import ./deps.nix' -i bash.Steps To Reproduce
Write a script that looks something like
Expected behavior
It shouldn't matter what my cwd is when I execute this, it should behave the same and import the
deps.nixfile that lives right next to the script.Actual behavior
It tries to import
./deps.nixfrom whatever my cwd is.nix-env --versionoutputnix-env (Nix) 2.3.7