We do the same with Nix, the shebang line looks like this:
#! nix-shell -i python3 -p "python312.withPackages (pkgs: [ pkgs.boto3 pkgs.click ])"
With this, the only requirement is Nix on the system, you don't even need Python to be installed! While that is true, there are still lots of PyPI packages not yet packaged with nixpkgs, so this is not as universal an approach as uv.
> you don't even need Python to be installed!
Note that this is exactly the case in TFA - uv takes care of installing Python ad-hoc.
Yup, and you can apply the same technique to any language. The obvious example is bash with all the dependencies specified, but I’ve also hacked up quick single file rust scripts using nix shebangs.
Having Nih installed is much stronger requirement than having uv
How to do the same thing with `nix shell` (The flake based command) instead of `nix-shell`?