News for hackers. Stuff that matters.
Re:Why I love NixOS by laserbeam on Monday March 23, 2026 @02:50AM (#47486183)
Can you share some good examples of how you use nix shells with python for one off scripts? I am still figuring out how python interacts with nixos :(
Re:Why I love NixOS by squiggleblaz on Monday March 23, 2026 @04:50AM (#47486849)
Not the greatest fan of python, but when I've got to run a python script, I do `nix-shell -p 'python3.withPackages (ps: [ps.requests])' --command 'python3 your-script.py'` Note that there is one argument to -p and one argument to --command -- both are quoted. The argument to -p is a nix expression that will provide a python3 command, referring to a python3 with the requests package. The argument to --command is a bash script that will run python3 with the argument "your-script.py" i.e. it will run your-script.py with the python3 that has the requests package.

I think there's ways you can autoderive a python3 with specific packages from python dependency files, but I can't help you there. I do find AI to be reasonably helpful for answering questions like this: it just might sometimes require a bit of help that you want to understand the answer rather than receive a perfect packaged shell.nix file.

Re:Why I love NixOS by codethief on Monday March 23, 2026 @09:29AM (#47489284)
Do you have to figure this out? Sure, it's nice and "pure" if everything is configured through Nix but there is something to be said about being pragmatic. Personally, I just enabled nix-ld[0] and use uv to install and handle my Python versions and package dependencies. Much, much easier.

[0]: https://mynixos.com/nixpkgs/option/programs.nix-ld.enable

Re:Why I love NixOS by perrygeo on Monday March 23, 2026 @09:50AM (#47489532)
Easier and largely compatible with the rest of the world. Solving problems with "If we all switched to NixOS..." is a non-starter in most organizations.

My rule of thumb: keep a strict separation between my projects (which change constantly) and my operating system (which I set up once and periodically update). Any hard nix dependency inside the project is a failure of abstraction IMO. Collaborating with people on other operating systems isn't optional!

In practice this means using language-specific package management (uv, cargo, etc) and ignoring the nix way.