Flakes: nix-shell interpreter trick equivalent?

I love using nix-shell as an interpreter. (manual reference).

You can also see a code example of this in NUR’s CI.

I haven’t seen a way to do this using nix shell or other flakes era subcommands.

Do you know how to do this?

6 Likes

Last I looked this was unsupported. There’s an upstream issue that suggests it’s something for the future, but there’s no discussion around it I can see: nix dev-shell / run: Support using as a #! interpreter · Issue #3046 · NixOS/nix · GitHub

Would be really cool if someone found time to pick that up :slight_smile: For the time being I’m still using nix-shell for this, which can at least be made to use your system’s nixpkgs flake like so: nixos-hosts/flake.nix at 47d4e82358b40c5c61ffa58d3c2a3326d09cbeea · TLATER/nixos-hosts · GitHub

2 Likes