Nix-runner: Tidy shell shebangs with nix flakes

I’d like to announce nix-runner, which is a small utility I wrote because I was tired of waiting for a flakes-oriented successor to the shell shebang mode of nix-shell.

It’s really just a simple sed processor that generates a small launcher script with nix shell but it’s been super-useful to me, so I thought I might as well publish it.

You can check it out at GitHub - clhodapp/nix-runner: Tidy shell shebangs with nix flakes


Amazing idea, love it !


As a side note: Did you hear about GitHub - BrianHicks/nix-script: write scripts in compiled languages that run in the nix ecosystem, with no separate build step? It does not focus on reproducability as much as nix-runner, but it produces cached scripts (maybe nix-runner also does that, I do not know). nix-script has helper functions that work well together with haskell, and bash.

Hey, yeah, I’m aware of that project but I believe that the focus is a little different: I think that project is really about making it so you can use compiled languages as scripting languages. That’s why caching is a central part of their value proposition: They’re talking about caching the results of the compilation process. My project is more about controlling the execution environment for interpreted languages. Thus, I actually get some amount of caching “for free” from the nix store. I do also believe that nix-script is anchored in the less-reproducible pre-Flakes nix ecosystem. I specifically set out to make something Flakes-based, since I believe that this has been a gap so far.

1 Like

I see. It may be that the focus is on compiled languages, but it works very well with scripting languages such as bash. I have a lot of bash scripts using nix-script. It certainly does not allow pinning of Nixpkgs like nix-runner. I think it uses the Nixpkgs version available in the system.