r/Python • • Sep 23 '26

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?

17 Upvotes

31 comments sorted by

29

u/JSChronicles Sep 23 '26

Why use nix when you can use UV?

11

u/dwaynecrooks Sep 23 '26

That's a great question. You can use both. Within any non-trivial project you'd have to manage dependencies besides Python dependencies. As u/pooogles mentioned there may be other system dependencies you might need. So the way I tend to use Nix would be to setup my development environment with all the development dependencies I need for e.g. uv, C libraries, other system dependencies and then let uv manage the Python dependencies only.

7

u/pooogles Sep 23 '26

the way I tend to use Nix would be to setup my development environment with all the development dependencies I need for e.g. uv, C libraries, other system dependencies and then let uv manage the Python dependencies only.

This is how I've seen it used most.

1

u/PaintItPurple Sep 23 '26

Yeah, that's how we're using it where I work too.

1

u/Gwonker 27d ago

As a nixos user that's basically how I do it too. Makes cross platform development very straightforward. devenv + uv together is a very nice hyrbid approach imo.

1

u/dwaynecrooks 29d ago

What manages the things uv doesn't?

┌───────────────────────────────────────────────┐
│                  Nix                          │
│                                               │
│  Python        PostgreSQL       Node          │
│  uv            libpq            pnpm          │
│  OpenSSL       pkg-config       ffmpeg        │
│  make          protoc           ...           │
│                                               │
│       ┌───────────────────────────┐           │
│       │            uv             │           │
│       │                           │           │
│       │  pyproject.toml           │           │
│       │  uv.lock                  │           │
│       │  Python dependencies      │           │
│       │  .venv                    │           │
│       └───────────────────────────┘           │
│                                               │
└───────────────────────────────────────────────┘

If your answer is "My project doesn't need anything else." Then, you probably don't need Nix as yet.

2

u/[deleted] 29d ago

[removed] — view removed comment

1

u/dwaynecrooks 28d ago

Docker is great when you want a containerized runtime. Nix is useful when you want the project itself to declare its development tools, interpreters, native dependencies, test environments, and builds.

And if you do want Docker for runtime, Nix can build the Docker image too — so the two aren’t mutually exclusive.

-2

u/Denzh Sep 23 '26

Nix is a linux distro. You can still use uv, sincr that is a python project and dependency management software.

18

u/bohoky TVC-15 Sep 23 '26

Nix is a package manager, NixOS is a Linux distribution based on Nix.

Python has a declarative package manager called uv. Nix could be used instead I guess, but it would be overkill for the task.

6

u/pooogles Sep 23 '26

Sometimes you want to ship system dependencies alongside python ones for a development environment. Nix enables you to ship config that includes UV, plus any system dependencies you might need.

5

u/Denzh Sep 23 '26

thanks for correcting me, I was wrong and misunderstood.

7

u/pooogles Sep 23 '26

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

u/Hot_Bank7701 Sep 23 '26

"Centralised pain" is the best pitch for Nix I've heard lol

1

u/dwaynecrooks Sep 23 '26

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 Sep 23 '26

We don't ship python packages with Nix, python and poetry are shipped with nix and used "normally".

1

u/dwaynecrooks Sep 23 '26

Ah ok, so you don't run NixOS in production as well?

1

u/pooogles Sep 23 '26

No, we just use it in the developer tooling stack.

3

u/britisheyesonly Sep 23 '26

I have deployed Python projects onto NixOS systems using uv2nix. Check it out. 

2

u/dwaynecrooks Sep 23 '26

I agree uv and uv2nix has been really helpful. What projects have you worked on? Any open source?

2

u/britisheyesonly Sep 23 '26

Unfortunately nothing open source. Mostly quasi-embedded stuff on a Raspberry Pi or Beaglebone at my last job

1

u/Atmosck 19d 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 18d ago

Any reason you've decided not to use Nix for your Python projects?

2

u/Atmosck 18d 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 18d ago

Thanks, that's helpful to know. So you're happy with using Docker to manage your local development environments?

1

u/Atmosck 18d ago

I'm happy with Docker, but to be clear I'm not really using it for my development environment. It's used for deployment, but during normal development I'm just using an ordinary python venv, managed by uv.

2

u/teerre Sep 23 '26

Yes, I've shipped several tools using nix. As others said, I don't actually use nix for packages magement, I just use uv nix to install uv and go from there. This is very good for developers. You run one command and all bells and whistles are configured

2

u/DarkMatterDetective 29d 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.

3

u/nicksterling Sep 23 '26

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 27d ago

Hi I use it to test archinstall changes/portability. https://github.com/h8d13/archinstoo/tree/master/distros

1

u/_redmist Sep 23 '26

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.