6 ms·
Nix allows you to do this with any language and required dependency: https://wiki.nixos.org/wiki/Nix-shell_shebang https://wiki.nixos.org/wiki/Nix-shell_shebang
by Rucadi 10mo ago
Nix allows you to do this with any language and required dependency:
https://wiki.nixos.org/wiki/Nix-shell_shebang https://wiki.nixos.org/wiki/Nix-shell_shebang
- albertoCaroM 10mo agoWhoa! This is a revelation. I already loved Nix and used nix-shell extensively, but this is the missing piece: fully reproducible Python scripts without compromise.
- luz666 10mo agoOr install direnv and put your dependencies into a shell.nix, setup the bash hook according the manual, create the .envrc with the content "use nix". Then type "direnv allow". Then you can do e.g. use other persons python scripts without modifying their shebang.
- HumanOstrich 10mo agoNow you have to set up Nix first and deal with that nightmare of a learning curve. Just to auto-install some dependencies for a script. Might as well rewrite all your scripts in Rust too while you're layering on unholy amounts of complexity.
- Diti 10mo agoIt’s like Vim, you learn it once, and you keep using it forever once you’re used to it. I’m so thankful to see a flake.nix file in every single cool project on code forges.
- HumanOstrich 10mo agoYea that's a common theme of excuses for both Rust and Nix. Wrong though, because most anyone who can use a computer at all can learn the basics of Vim. Seeing that flake.nix badge of complexity lets me know a project will be a nightmare to set up and will break every other week. It's usually right next to the Cargo.toml badge with 400 dependencies underneath.
- kokada 10mo agoNix with Flakes never randomly break, I still have projects from 3 or 4 years ago that I can still run `nix build` and getting it running. Yes, if you try to update the `flake.lock` this may introduce breakages, but this is expected if you're pining `nixos-unstable` instead of a stable branch.
- Rucadi 10mo agoTo be honest I don't know what to say, you can use nix in many ways, and you don't even require to know the language. The easiest entry-point is to just use it like a package manager, you install nix (which is just a command...) and then you have available the whole set of packages which are searchable from here: https://search.nixos.org/packages https://search.nixos.org/packages nix-shell is just to download&add programs temporary to your PATH. I don't feel that this is harder than something like "sudo apt install -y xxxxx" but for sure more robust and portable, and doesn't require sudo. If at some point you want to learn the language in order to create configurations or packaging software, it may require to check a lot more documentation and examples, but for this I think it's pretty straightforward and is not harder than any other package manager like aptitude, homebrew or pacman.
- Diti 10mo agoI’m not sure what you mean by “a nightmare to set up”. You install Nix on your current OS with the determinate.systems installer, and you enter `nix run github:johndoe/project-containing-a-flake-dot-nix-file` to try out the project and have the full reproducible build taken care of by Nix. Sure, installing packages the proper way requires a little bit more setup (Home Manager, most likely, and understanding where is the list of packages and which command to build to switch configuration), but as trivial as other complex tasks most of us hackers are capable of doing (like using `jq` or Vim).