• The only FHS paths for executables that NixOS populates by default are /bin/sh and /usr/bin/env.
  • #!/usr/bin/env is one of the shebangs Python builds in support for on Windows.

However, multiple arguments (such as in #!/usr/bin/env awk -f) may be problematic due to, in this case, the entire awk -f being treated as a single argument. GNU coreutils 8.30 (2018) added the env -S to split multiple parameters, so #!/usr/bin/env -S awk -f will execute awk -f as intended. This had already been present in FreeBSD (since 6.0; 2005) and macOS versions. But it’s not POSIX, and not in NetBSD, OpenBSD, BusyBox, Heirloom.

I’ve written things like #!/bin/awk -f in the past, but due to my use of NixOS I thought to move to #!/usr/bin/env -S despite its incompatibility with some other platforms. I imagine a certain hat-and-sunglasses-wearing blue whale telling me off for this, should he ever read this post. However, I did end up finding some other more portable solutions suggested. This is the one I ended up going with, e.g. in allegro:

#!/bin/sh  
exec awk "$(sed 1,2d "$0")" "$@"  
# ex: ft=awk

Further reading