ners / nix-monitored

A transparent wrapper around Nix that pipes its output through Nix Output Monitor
MIT License
19 stars 3 forks source link

Wrapped `nix-shell` binary breaks Nix shell shebang #4

Open campbellcole opened 2 months ago

campbellcole commented 2 months ago

Any script that uses the nix-shell shebang when nix.monitored.enable = true; is interpreted as a Nix expression instead of the chosen interpreter.

For example, the following script:

#! /usr/bin/env nix-shell
#! nix-shell -i bash -p inotify-tools

echo "test"

produces the following error:

error: undefined variable 'echo'

       at /fake/path/example.sh:4:1:

            3|
            4| echo "test"
             | ^
            5|

With the nix-monitored module enabled, is there any built-in way to access the original nix-shell binary? Perhaps this could be worked around by providing a nix-shell-unwrapped binary in the path (if that isn't already a thing).

Thanks

campbellcole commented 2 months ago

I just found a workaround. Using the flake shebang still works, so I just replaced my shebang with:

#! /usr/bin/env -S nix shell nixpkgs#inotify-tools --command bash

# ...