Python in Nix/NixOS

2023.05.03
ProjectMaintainedDescriptionPurityCompatibility
venv100%?
mach-nix
pypi2nix
pip2nix
buildPythonPackage
[TODO] poetry
[TODO] dream2nix

pip2nix

Noted: Latest version of pip2nix only use python39. While nixpkgs 22.11 (current stable) is python310. I dont to install multiple versions of python3.

If pip2nix can overcome the disadvantage of that generate a long list of python packages, and reuse python3Packages in nixpkgs, I would prefer to use pip2nix completely.

Currently, I use buildPythonPackage.

buildPythonPackage

pkgs.python3Packages.buildPythonPackage

venv

Use virtualenv, pip is available, no need to write nix expressions to install packages.

Code see https://xieby1.github.io/scripts/index.html#venvnix

poetry

2022.05.15

According to What is the correct way to setup pip with nix to install any python package in an isolated nix environment, I found two useful tools to install python packages in Nix/NixOS

  • [TODO] poetry
  • mach-nix

mach-nix

mach-nix github repo: github.com/DavHau/mach-nix

Here is [python_mach.nix]({{ site.repo_url }}/scripts/shell/python_mach.nix), an example which create a shell with a python package called expmcc.