[![](https://github.com/nix-community/poetry2nix/workflows/CI/badge.svg)](https://github.com/nix-community/poetry2nix/actions?query=branch%3Amaster+workflow%3ACI) [![Chat on Matrix](https://matrix.to/img/matrix-badge.svg)](https://matrix.to/#/#poetry2nix:blad.is) # poetry2nix _poetry2nix_ turns [Poetry](https://python-poetry.org/) projects into Nix derivations without the need to actually write Nix expressions. It does so by parsing `pyproject.toml` and `poetry.lock` and converting them to Nix derivations on the fly. For more information, see [the original announcement post](https://www.tweag.io/blog/2020-08-12-poetry2nix/). ## Maintenance status: ⚠️ Unmaintained ⚠️ The creator & long-term maintainer of poetry2nix ([@adisbladis](https://github.com/adisbladis)) is no longer using Poetry or Poetry2nix. This means that [poetry2nix is looking for maintainers](https://github.com/nix-community/poetry2nix/issues/1865). Poetry has a number of upcoming large changes, which poetry2nix is unlikely to gain support for: - [PEP-621 pyproject.toml metadata](https://github.com/python-poetry/poetry-core/pull/708) - [Poetry 2.0](https://github.com/python-poetry/poetry/issues/9448) If you are not already using Poetry & Poetry2nix, do consider [`uv`](https://docs.astral.sh/uv/) & [`uv2nix`](https://github.com/adisbladis/uv2nix). ## Quickstart Non-flake You can turn your Python application into a Nix package with a few lines by adding a `default.nix` next to your `pyproject.toml` and `poetry.lock` files: ```nix # file: default.nix let sources = import ./nix/sources.nix; pkgs = import sources.nixpkgs { }; # Let all API attributes like "poetry2nix.mkPoetryApplication" # use the packages and versions (python3, poetry etc.) from our pinned nixpkgs above # under the hood: poetry2nix = import sources.poetry2nix { inherit pkgs; }; myPythonApp = poetry2nix.mkPoetryApplication { projectDir = ./.; }; in myPythonApp ``` The Nix code being executed by `import sources.poetry2nix { inherit pkgs; }` is [./default.nix](./default.nix). The resulting `poetry2nix` attribute set contains (only) the [API attributes](#api) like `mkPoetryApplication`. Hint: This example assumes that `nixpkgs` and `poetry2nix` are managed and pinned by the handy [niv tool](https://github.com/nmattia/niv). In your terminal just run: ```shell nix-shell -p niv niv init niv add nix-community/poetry2nix ``` You can then build your Python application with Nix by running: ```shell nix-build default.nix ``` Finally, you can run your Python application from the new `./result` symlinked folder: ```shell # replace