The [[NixOS]] wiki has [several suggestions](https://wiki.nixos.org/wiki/Python) and examples for packaging [[Python]] libraries and apps for use in [[Nix]]. The [Packaging/Python](https://nixos.wiki/wiki/Packaging/Python) wiki article has more. In general, a package is defined like this: ```nix # toolz.nix { lib, buildPythonPackage, fetchPypi, setuptools, wheel, }: buildPythonPackage rec { pname = "toolz"; version = "0.10.0"; src = fetchPypi { inherit pname version; hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA="; }; # do not run tests doCheck = false; # specific to buildPythonPackage, see its reference pyproject = true; build-system = [ setuptools wheel ]; } ``` This will fetch the package from [[Pypi]] and build it into a derivation. It can then be used with in an override to inject it into the environment when used by a `shell.nix`. Packages may be created from several different Python package definition formats including [`pyproject.toml`](https://wiki.nixos.org/wiki/Python#With_pyproject.toml) and [`setup.py`](https://wiki.nixos.org/wiki/Python#With_setup.py). # setup.py ```nix # default.nix { pkgs ? import <nixpkgs> {} }: pkgs.python3Packages.buildPythonApplication { pname = "myFlaskApp"; version = "0.1.0"; propagatedBuildInputs = with pkgs.python3Packages; [ flask ]; src = ./.; } ``` Basically, just use `buildPythonApplication`.