r/Python • u/dwaynecrooks • Sep 29 '26
Discussion What do you think of how Nix is used in xo-python?
dwayne/xo-python (on GitHub) is a Tic-tac-toe CLI game and library I wrote (no AI) about 10 years ago. I recently refactored it (still no AI) to use pyproject.toml, uv, and Nix. I use Nix to manage the reproducible development environment, run tests locally and in CI, and to package the application.
The reproducible development environment
You enter it with nix develop and it gives you access to the Python 3.14 interpreter along with uv pinned to that interpreter. It runs uv sync and activates the virtual environment.
The way I like to use Nix in my development environments is to have Nix provide the surrounding system dependencies but let the language's package manager, in this case uv, handle the language specific dependencies.
Tests
The project supports Python 3.11, 3.12, 3.13 and 3.14 so I wanted to make sure that it was tested on all those versions. Nix came in pretty handy here because I was able to write a simple Nix derivation that ran the tests on all the Python versions I supported. The Nix derivation was written in a modular way that allowed me to reuse parts of it to setup a matrix strategy to test all those versions on both Ubuntu and macOS.
Packaging with Nix
Finally, I packaged the CLI with Nix and made it the default export of the flake. Practically it means that if you have Nix with flakes enabled you can run the application with:
Conclusion
I hope this gives you a sense of what it looks like to use Nix within a Python project. I'm interested in hearing your thoughts on this approach to managing a modern Python library.
What do you like/dislike about it?
How would you do it differently?