5 ms·
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
by kissgyorgy 2y ago
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!
- skavi 2y agoYup, 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. https://nixos.wiki/wiki/Nix-shell_shebang https://nixos.wiki/wiki/Nix-shell_shebang
- execat 2y agoHow to do the same thing with `nix shell` (The flake based command) instead of `nix-shell`?
- skowalak 2y agoWhile 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.
- falcor84 2y ago> 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.
- Tractor8626 2y agoHaving Nih installed is much stronger requirement than having uv