Nix shell with shebang

Hi,

I understand that I can use the nix-shell command in a shebang (see e.g. http://chriswarbo.net/projects/nixos/nix_shell_shebangs.html), but I was wondering if this is also possible with the new nix shell and flakes?

Thanks

2 Likes

Not yet, AFAIK. There’s some effort in https://github.com/NixOS/nix/pull/5189. I think (but am not certain–perhaps @tomberek can comment?) when it says that it’s blocked on run/shell/develop semantics, it’s referring at least in part to some of what’s covered in Rename 'nix shell' · Issue #4715 · NixOS/nix · GitHub

4 Likes

This has been blocked for a bit because I’ve been trying to recover a common use-case of bringing in things like python libraries, but the easy/common usage does not provide the expected outcome.

1 Like

This has been merged about a month ago: Shebang flakes v2 by roberth · Pull Request #8327 · NixOS/nix · GitHub

Docs: nix - Nix Reference Manual

3 Likes