Re:Self-contained Python scripts with uv
by kissgyorgy on Sunday March 30, 2025 @02:50AM
(#43521949)
We do the same with Nix, the shebang line looks like this:
With this, the only requirement is Nix on the system, you don't even need Python to be installed!
[ Parent
| on HN ]
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.
How to do the same thing with `nix shell` (The flake based command) instead of `nix-shell`?
Maybe `#! /usr/bin/env -S nix shell `?
it is a bit more annoying: https://nix.dev/manual/nix/2.22/command-ref/new-cli/nix3-she...
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.
Re:Self-contained Python scripts with uv
by Tractor8626 on Sunday March 30, 2025 @08:53AM
(#43523782)
Having Nih installed is much stronger requirement than having uv
im not sure this is true