[![](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 announcement post on the Tweag blog](https://www.tweag.io/blog/2020-08-12-poetry2nix/). ## 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