When using a nix-shell shebang in a script, nix-shell doesn't load shell.nix if it is not in the working directory.
This contradicts the nix-shell manpage:
If path is not given, nix-shell defaults to shell.nix if it exists, and default.nix otherwise.
user@xps ~/bug/nix-shell/subdir $ echo i-am-shell-nix >shell.nix
user@xps ~/bug/nix-shell/subdir $ echo i-am-default-nix >default.nix
user@xps ~/bug/nix-shell/subdir $ echo '#!/usr/bin/env nix-shell' >tool
user@xps ~/bug/nix-shell/subdir $ chmod a+x tool
user@xps ~/bug/nix-shell/subdir $ ./tool
error: undefined variable 'i-am-shell-nix' at /home/user/bug/nix-shell/subdir/shell.nix:1:1
user@xps ~/bug/nix-shell/subdir $ cd ..
user@xps ~/bug/nix-shell $ ./subdir/tool
error: undefined variable 'i-am-default-nix' at /home/user/bug/nix-shell/subdir/default.nix:1:1
user@xps ~/bug/nix-shell $ rm subdir/default.nix
user@xps ~/bug/nix-shell $ ./subdir/tool
error: getting status of '/home/user/bug/nix-shell/subdir/default.nix': No such file or directory
The latter invocations should use shell.nix.
This is related to #496 but doesn't involve .
A workaround:
#!/usr/bin/env nix-shell
#!nix-shell ./shell.nix
When using a nix-shell shebang in a script, nix-shell doesn't load shell.nix if it is not in the working directory.
This contradicts the nix-shell manpage:
The latter invocations should use
shell.nix.This is related to #496 but doesn't involve
.A workaround: