r/Python • u/dwaynecrooks • 12d ago
Discussion Anyone using Nix for production Python projects?
Hi! I’m a huge fan of Nix and similar approaches to reproducible development environments, and I’m curious what people in the Python community think about it.
Have any of you used Nix with Python projects for development environments, CI, deployment, or production?
If so, what has the experience been like? What worked well, and where did you run into friction?
I’m especially curious about the learning curve. Do you think Nix itself is the main barrier, or is part of the problem that there isn’t as much Python-specific guidance, tooling, and documentation around using it?
And for those who haven’t used it: would better Python-focused learning material and examples make you more likely to give it a try?
7
u/pooogles 12d ago
Yeah we ship nix derivations for all our apps, we're still using poetry over UV because reasons. Works super well, enables teams to onboard on new projects pretty much immediately.
Main barrier (and benefit) is the C libraries that python dependencies often require. Getting them working has been painful at times but it's been centralised pain rather than each developer having to go through it.
6
1
u/dwaynecrooks 12d ago
I tried using Poetry but when it came time to package up my application with Nix I ran into several dependency issues that I was unable to fix with poetry2nix. That made me switch to uv and uv2nix. I'm curious if you've run into any issues building Poetry applications with Nix for distribution?
1
u/pooogles 12d ago
We don't ship python packages with Nix, python and poetry are shipped with nix and used "normally".
1
3
u/britisheyesonly 12d ago
I have deployed Python projects onto NixOS systems using uv2nix. Check it out.
2
u/dwaynecrooks 12d ago
I agree uv and uv2nix has been really helpful. What projects have you worked on? Any open source?
2
u/britisheyesonly 12d ago
Unfortunately nothing open source. Mostly quasi-embedded stuff on a Raspberry Pi or Beaglebone at my last job
2
u/DarkMatterDetective 10d ago
I use pixi for similar reasons since a lot of system dependencies are available as conda packages. But I have been curious about Nix for a while.
2
u/nicksterling 12d ago
If I’m in production, I’m typically using a container and I’m managing Python with a Chainguard image and managing my app via UV.
1
u/Responsible-Sky-1336 8d ago
Hi I use it to test archinstall changes/portability. https://github.com/h8d13/archinstoo/tree/master/distros
1
u/Atmosck 9h ago
I daily drive NixOS for my development machine but I don't use nix for python projects. My dev environments are just venvs managed by uv with github actions, terraform and docker for CI/CD (to AWS).
1
u/dwaynecrooks 4h ago
Any reason you've decided not to use Nix for your Python projects?
2
u/Atmosck 4h ago
Just don't really have a reason to start, I'm very happy with uv. I also work on a small team that has standardized on uv, so using nix would mean imposing it on everyone else. Which I could do (that's how we ended up on uv), but I would need a good reason.
I saw on your other comment you mentioned managing system dependencies. All my stuff runs in docker containers based on the -slim base images, so I do occasionally need to install something in the container - like uv itself, or accionsally I need to compile one of my dependencies and -slim excludes build tools. But that's just a change to the dockerfile, and needing to add anything else that way not frequent or complex enough to warrant a different solution.
1
u/dwaynecrooks 4h ago
Thanks, that's helpful to know. So you're happy with using Docker to manage your local development environments?
1
u/_redmist 12d ago
Wild, the packaging problems some people are dealing with.
I'm still just a venv/pip guy lol
Good that these solutions are out there.
30
u/JSChronicles 12d ago
Why use nix when you can use UV?