News for hackers. Stuff that matters.
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by pxc on Monday January 23, 2023 @04:12PM (#34495120)
> AFAICT, there's no way to use the Flakes-based tools (`nix develop` and such) in the shebang of a script

For now there's nix-runner: https://github.com/clhodapp/nix-runner

Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by SAI_Peregrinus on Monday January 23, 2023 @05:19PM (#34495922)
Nice, but that appears to need the (non-portable) `-S` option to `env`. POSIX only requires a single argument string to pass to the utility invoked (though the documentation has it as [argument...] the OPERANDS section uses the singular "a string" form)[1]. Further arguments may be ignored (it's implementation dependent). With `nix-shell` your shebang can be `#! /usr/bin/env nix-shell` and subsequent arguments can be on the following lines, and `nix-shell` itself knows to parse that. Busybox's `env` doesn't support `-S`, and Busybox is the standard shell environment in Alpine (for a common use).

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/e...