Announcing pyproject.nix - Nix tooling for Python

Pyproject.nix is a collection of Nix utilities to work with Python project metadata in Nix. It mainly targets PEP-621 compliant pyproject.toml files and data formats, but also implement support for legacy formats such as requirements.txt.

Unlike 2nix tooling this is not (mainly) something to help you package your projects, it instead focuses on implementing lower level packaging metadata correctly with good documentation and testing.

Some use cases for it is:

  • Write py2nix tooling (it’s already used in poetry2nix & dream2nix)
  • Package requirements.txt based projects
  • Your use case here

Check out the docs!


Does it support monorepo packages dependencies? For example, my-package and my-dependency are python packages with default.nix and pyproject.toml inside and my-package depends on my-dependency in its default.nix.
my-package package and its dependencies could be installed to the virtualenv using poetry install

name = "my-package"

aiohttp = "^"

my-dependency = { path = "../my-dependency/", develop = true }

Last time I’ve tried pyproject.toml support in nixpkgs it didn’t want to work with dependencies declared like this and I have to use specifically for building with nix.

That’s a much higher level concern than what pyproject.nix deals with.
Pyproject.nix is not a tool to manage whole Python package sets, it’s a toolkit to build these higher level tools with.

Managing sets is a job for tools like poetry2nix & dream2nix.

1 Like

Pdm2nix is my vision for how to model py2nix tools to manage entire package sets and ingest lock files

It hooks into pyproject.nix, and the two combined provides a way to fully manage projects end to end.