{"id":14968026,"url":"https://github.com/on-nix/python","last_synced_at":"2025-08-25T15:09:03.594Z","repository":{"id":43327556,"uuid":"400700123","full_name":"on-nix/python","owner":"on-nix","description":"Extensive collection of Python projects from PyPI, for Nix!","archived":false,"fork":false,"pushed_at":"2022-11-08T17:25:09.000Z","size":5468,"stargazers_count":125,"open_issues_count":20,"forks_count":46,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-22T08:53:50.463Z","etag":null,"topics":["nix","nixos","nixpkgs","pypi","python"],"latest_commit_sha":null,"homepage":"https://python.on-nix.com","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/on-nix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-28T04:22:19.000Z","updated_at":"2025-07-10T00:12:10.000Z","dependencies_parsed_at":"2022-09-05T18:22:40.090Z","dependency_job_id":null,"html_url":"https://github.com/on-nix/python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/on-nix/python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/on-nix%2Fpython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/on-nix%2Fpython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/on-nix%2Fpython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/on-nix%2Fpython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/on-nix","download_url":"https://codeload.github.com/on-nix/python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/on-nix%2Fpython/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272084844,"owners_count":24870584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nix","nixos","nixpkgs","pypi","python"],"created_at":"2024-09-24T13:39:07.762Z","updated_at":"2025-08-25T15:09:01.677Z","avatar_url":"https://github.com/on-nix.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python on Nix\n\nExtensive collection\nof [Python][python] projects\nfrom the [Python Packaging Index][pypi].\nThat can be used with the [Nix][nix] package manager.\n\nCheck out the examples at [python.on-nix.com](https://python.on-nix.com/)!\n\n- Scope:\n  - :heavy_check_mark:\n    All [active Python releases][python_releases]\n    (`3.7`, `3.8`, `3.9`, `3.10`)\n  - :heavy_check_mark: 1700+ [projects][projects] already packaged,\n    prioritized by their popularity\n    according to [libraries.io](https://libraries.io/PyPI)\n- Quality:\n  - :heavy_check_mark: It is 100% Nix, with love :heart:\n  - :heavy_check_mark: Data integrity checksums are used everywhere\n  - :heavy_check_mark: We test projects before you use them\n- Platforms:\n  - :heavy_check_mark: Linux x86-64\n  - :construction: MacOS x86-64\n- Performance:\n  - :heavy_check_mark: Every project is built with a minimal closure and size\n  - :heavy_check_mark: A highly granular cache\n\nWhy?\n\nTo make using [Nix][nix] on [Python][python] projects\nas simple as possible!\n\nJust:\n\n1. Copy and paste the examples,\n2. Select the [Python][python] projects of your choice,\n3. Enjoy! :rocket:\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n# Contents\n\n- [List of available projects](#list-of-available-projects)\n- [Concepts](#concepts)\n  - [Applications and Libraries](#applications-and-libraries)\n- [Using with Nix stable](#using-with-nix-stable)\n  - [Trying out single projects](#trying-out-single-projects)\n  - [Installing applications in your system](#installing-applications-in-your-system)\n  - [Creating Python environments with many applications and libraries](#creating-python-environments-with-many-applications-and-libraries)\n    - [Compatibility with Nixpkgs](#compatibility-with-nixpkgs)\n- [Using with Nix unstable (Nix Flakes)](#using-with-nix-unstable-nix-flakes)\n  - [Trying out single projects](#trying-out-single-projects-1)\n  - [Installing applications in your system](#installing-applications-in-your-system-1)\n  - [Creating Python environments with many applications and libraries](#creating-python-environments-with-many-applications-and-libraries-1)\n    - [Compatibility with Nixpkgs](#compatibility-with-nixpkgs-1)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# List of available projects\n\nCheckout [python.on-nix.com](https://python.on-nix.com)\n\n# Concepts\n\n## Applications and Libraries\n\nOn Python, projects can be used in two ways:\n\n- As applications: Commands that you can run from the command line:\n\n  - [AWS CLI](https://pypi.org/project/awscli/): `$ aws`\n  - [Bandit](https://pypi.org/project/bandit/): `$ bandit`\n  - [PyTest](https://pypi.org/project/pytest/): `$ pytest`\n  - ...\n\n- As libraries: Python modules that you can import in your project:\n\n  - [Boto3](https://pypi.org/project/boto3/): `\u003e\u003e\u003e import boto3`\n  - [Django](https://pypi.org/project/django/): `\u003e\u003e\u003e from django import *`\n  - [PyTest](https://pypi.org/project/pytest/): `\u003e\u003e\u003e import pytest`\n  - ...\n\nSome projects (like PyTest) can be used in both ways\nwhile others can only be used as an application or as a library,\nbut not both\n\n# Using with Nix stable\n\n## Trying out single projects\n\nYou can launch an ephemeral environment where\nthe applications and libraries provided by a project are available.\n\nFor example:\n\n```bash\n$ nix-shell \\\n  -A 'projects.\"awscli\".\"1.20.31\".python39.dev' \\\n  https://github.com/on-nix/python/tarball/main\n```\n\nIn general the format is: `'projects.\"\u003cproject\u003e\".\"\u003cversion\u003e\".\u003cpythonVersion\u003e.dev'`\n\nNow enjoy!\n\n```bash\n[nix-shell] $ aws --version\n              aws-cli/1.20.31 Python/3.9.6 Linux/5.10.62 botocore/1.21.31\n[nix-shell] $ python -c 'import awscli; print(awscli)'\n              # ...\n[nix-shell] $ exit\n```\n\n## Installing applications in your system\n\nYou can permanently install the applications of a project in your system.\n\nFor example:\n\n```bash\n$ nix-env \\\n  -iA 'apps.\"awscli\".\"1.20.31\"' \\\n  -f https://github.com/on-nix/python/tarball/main\n\n$ nix-env \\\n  -iA 'apps.\"pytest\".\"latest\"' \\\n  -f https://github.com/on-nix/python/tarball/main\n```\n\nIn general the format is: `'apps.\"\u003cproject\u003e\".\"\u003cversion\u003e\"'`\n\nNow enjoy!\n\n```bash\n$ aws --version\n  aws-cli/1.20.31 Python/3.9.6 Linux/5.10.62 botocore/1.21.31\n\n$ pytest --version\n  pytest 6.2.5\n```\n\n## Creating Python environments with many applications and libraries\n\nFor more complex use cases where you are using many projects it's\na good idea to describe a Python environment with Nix.\n\nFor example:\n\n```nix\n# /path/to/my/env.nix\n\nlet\n  # Import Python on Nix\n  pythonOnNix = import\n    (builtins.fetchGit {\n      # Use `main` branch or a commit from this list:\n      # https://github.com/on-nix/python/commits/main\n      # We recommend using a commit for maximum reproducibility\n      ref = \"main\";\n      url = \"https://github.com/on-nix/python\";\n    })\n    {\n      # (optional) You can override `nixpkgs` here\n      # nixpkgs = import \u003cnixpkgs\u003e { };\n    };\n\n  # Pick the Python version of your choice:\n  # - `python37Env`: Python 3.7\n  # - `python38Env`: Python 3.8\n  # - `python39Env`: Python 3.9\n  # - `python310Env`: Python 3.10\n  env = pythonOnNix.python39Env {\n    name = \"example\";\n    projects = {\n      awscli = \"1.20.31\";\n      numpy = \"latest\";\n      requests = \"latest\";\n      torch = \"1.9.0\";\n    };\n  };\n\n  # `env` has two attributes:\n  # - `dev`: The activation script for the Python on Nix environment\n  # - `out`: The raw contents fo the Python site-packages\nin\n# Let's use the activation script:\nenv.dev\n```\n\nYou can now launch the environment!\n\n```bash\n$ nix-shell /path/to/my/env.nix\n```\n\nAfter doing this,\nthe specified dependencies will be available in your shell ! :rocket:\n\nAlso, you'll be able to use the applications and libraries provided\nby the projects in the environment:\n\n```bash\n$ python --version\n  Python 3.9.6\n$ aws --version\n  aws-cli/1.20.31 Python/3.9.6 Linux/5.10.57 botocore/1.21.31\n$ python -c 'import numpy; print(numpy.__version__)'\n  1.21.2\n$ python -c 'import requests; print(requests.__version__)'\n  2.26.0\n$ python -c 'import torch; print(torch.__version__)'\n  1.9.0+cu102\n```\n\n### Compatibility with Nixpkgs\n\nYou can use `Python On Nix` and `Nixpkgs` together.\n\nFor example:\n\n```nix\n# /path/to/my/expression.nix\n\nlet\n  # Import Nixpkgs\n  nixpkgs = import \u003cnixpkgs\u003e { };\n\n  # Import Python on Nix\n  pythonOnNix = import\n    (builtins.fetchGit {\n      # Use `main` branch or a commit from this list:\n      # https://github.com/on-nix/python/commits/main\n      # We recommend using a commit for maximum reproducibility\n      ref = \"main\";\n      url = \"https://github.com/on-nix/python\";\n    })\n    {\n      # Make Python on Nix use the same version of `nixpkgs`\n      # for maximum compatibility\n      inherit nixpkgs;\n    };\n\n  # Pick the Python version of your choice:\n  # - `python37Env`: Python 3.7\n  # - `python38Env`: Python 3.8\n  # - `python39Env`: Python 3.9\n  # - `python310Env`: Python 3.10\n  env = pythonOnNix.python39Env {\n    name = \"example\";\n    projects = {\n      awscli = \"1.20.31\";\n      numpy = \"latest\";\n      requests = \"latest\";\n      torch = \"1.9.0\";\n    };\n  };\n\n  # `env` has two attributes:\n  # - `dev`: The activation script for the Python on Nix environment\n  # - `out`: The raw contents of the Python virtual environment\nin\nnixpkgs.stdenv.mkDerivation {\n  # Let's use the activation script as build input:\n  buildInputs = [ env.dev ];\n  virtualEnvironment = env.out;\n\n  builder = builtins.toFile \"builder.sh\" ''\n    source $stdenv/setup\n\n    set -x\n\n    ls $virtualEnvironment\n    python --version\n    aws --version\n    python -c 'import numpy; print(numpy.__version__)'\n    python -c 'import requests; print(requests.__version__)'\n    python -c 'import torch; print(torch.__version__)'\n\n    touch $out\n\n    set +x\n  '';\n  name = \"example\";\n}\n```\n\nNow just `$ nix-build /path/to/my/expression.nix` ! :rocket:\n\n```bash\nthese derivations will be built:\n  /nix/store/4l51x7983ggxc8z5fmb5wzhvvx8kvn01-example.drv\n\nbuilding '/nix/store/4l51x7983ggxc8z5fmb5wzhvvx8kvn01-example.drv'...\n\n+ ls /nix/store/...-example-out\n  awscli              colorama  numpy            requests    torch\n  botocore            docutils  pyasn1           rsa         typing-extensions\n  certifi             idna      python-dateutil  s3transfer  urllib3\n  charset-normalizer  jmespath  pyyaml           six\n+ python --version\n  Python 3.9.6\n+ aws --version\n  aws-cli/1.20.31 Python/3.9.6 Linux/5.10.57 botocore/1.21.31\n+ python -c 'import numpy; print(numpy.__version__)'\n  1.21.2\n+ python -c 'import requests; print(requests.__version__)'\n  2.26.0\n+ python -c 'import torch; print(torch.__version__)'\n  1.9.0+cu102\n+ touch /nix/store/9cckx5zpbiakx507g253fv08hykf8msv-example\n```\n\n### Customization of and integration into existing development environments\n\nGiven an existing definition of a development environment using e.g. `mkShell` instead of `mkDerivation`:\n\n```nix\nlet\n  nixpkgs = builtins.fetchTarball {\n    # nixpkgs-unstable (2021-10-28)\n    url = \"https://github.com/NixOS/nixpkgs/archive/22a500a3f87bbce73bd8d777ef920b43a636f018.tar.gz\";\n    sha256 = \"1rqp9nf45m03mfh4x972whw2gsaz5x44l3dy6p639ib565g24rmh\";\n  };\nin\n{ pkgs ? import nixpkgs { } }:\n\npkgs.mkShell {\n  nativeBuildInputs = with pkgs; [\n    cmake\n    gdb\n    ninja\n    qemu\n  ] ++ (with llvmPackages_13; [\n    clang\n    clang-unwrapped\n    lld\n    llvm\n  ]);\n\n  hardeningDisable = [ \"all\" ];\n}\n```\n\nyou can integrate the `Python On Nix` development environment seamlessly via e.g.\n\n```nix\nlet\n  nixpkgs = builtins.fetchTarball {\n    # nixpkgs-unstable (2021-10-28)\n    url = \"https://github.com/NixOS/nixpkgs/archive/22a500a3f87bbce73bd8d777ef920b43a636f018.tar.gz\";\n    sha256 = \"1rqp9nf45m03mfh4x972whw2gsaz5x44l3dy6p639ib565g24rmh\";\n  };\nin\n{ pkgs ? import nixpkgs { } }:\nlet\n  pythonOnNix = import (\n    builtins.fetchGit {\n      ref = \"main\";\n      rev = \"2e735762c73651cffc027ca850b2a58d87d54b49\";\n      url = \"https://github.com/on-nix/python\";\n    }\n  ) { nixpkgs = pkgs; };\n  env = pythonOnNix.python39Env {\n    name = \"example\";\n    projects = {\n      \"awscli\" = \"latest\";\n      # You can add more projects here as you need\n      # \"a\" = \"1.0\";\n      # \"b\" = \"2.0\";\n      # ...\n    };\n  };\nin\npkgs.mkShell {\n  nativeBuildInputs =\n    [ env.dev ]\n    ++ (with pkgs; [ cmake gdb ninja qemu ])\n    ++ (with pkgs; with llvmPackages_13; [ clang clang-unwrapped lld llvm ]);\n  hardeningDisable = [ \"all\" ];\n}\n```\n\n# Using with Nix unstable (Nix Flakes)\n\nThis project is also offered as a Nix Flake.\n\n:warning: This section is for advanced Nix users.\nYou can skip its content\nas Nix Flakes is currently\nan **unstable** release of Nix.\n\n```bash\n$ nix flake show github:on-nix/python\n```\n\n## Trying out single projects\n\n- `$ nix develop 'github:on-nix/python#\"awscli-1.20.31-python39\"'`\n- `$ nix develop 'github:on-nix/python#\"pytest-latest-python37\"'`\n\n## Installing applications in your system\n\n- `$ nix profile install 'github:on-nix/python#\"awscli-1.20.31-python39-bin\"'`\n- `$ nix profile install 'github:on-nix/python#\"pytest-latest-python37-bin\"'`\n\n## Creating Python environments with many applications and libraries\n\n```nix\n# /path/to/my/project/flake.nix\n\n{\n  inputs = {\n    flakeUtils.url = \"github:numtide/flake-utils\";\n    nixpkgs.url = \"github:nixos/nixpkgs\";\n    pythonOnNix.url = \"github:on-nix/python\";\n    pythonOnNix.inputs.nixpkgs.follows = \"nixpkgs\";\n  };\n  outputs = { self, ... } @ inputs:\n    inputs.flakeUtils.lib.eachSystem [ \"x86_64-linux\" ] (system:\n      let\n        nixpkgs = inputs.nixpkgs.legacyPackages.${system};\n        pythonOnNix = inputs.pythonOnNix.lib.${system};\n\n        # Pick the Python version of your choice:\n        # - `python37Env`: Python 3.7\n        # - `python38Env`: Python 3.8\n        # - `python39Env`: Python 3.9\n        # - `python310Env`: Python 3.10\n        env = pythonOnNix.python39Env {\n          name = \"example\";\n          projects = {\n            awscli = \"1.20.31\";\n            numpy = \"latest\";\n            requests = \"latest\";\n            torch = \"1.9.0\";\n          };\n        };\n        # `env` has two attributes:\n        # - `dev`: The activation script for the Python on Nix environment\n        # - `out`: The raw contents fo the Python site-packages\n      in\n      {\n        devShells = {\n\n          # The activation script can be used as dev-shell\n          example = env.dev;\n\n        };\n      }\n    );\n}\n```\n\nYou can now launch the environment!\n\n```bash\n$ nix develop '.#example'\n```\n\nAfter doing this,\nthe specified dependencies will be available in your shell ! :rocket:\n\nAlso, you'll be able to use the applications and libraries provided\nby the projects in the environment:\n\n```bash\n$ python --version\n  Python 3.9.6\n$ aws --version\n  aws-cli/1.20.31 Python/3.9.6 Linux/5.10.57 botocore/1.21.31\n$ python -c 'import numpy; print(numpy.__version__)'\n  1.21.2\n$ python -c 'import requests; print(requests.__version__)'\n  2.26.0\n$ python -c 'import torch; print(torch.__version__)'\n  1.9.0+cu102\n```\n\n### Compatibility with Nixpkgs\n\nYou can use `Python on Nix` and `Nixpkgs` together.\n\nFor example:\n\n```nix\n# /path/to/my/project/flake.nix\n\n{\n  inputs = {\n    flakeUtils.url = \"github:numtide/flake-utils\";\n    nixpkgs.url = \"github:nixos/nixpkgs\";\n    pythonOnNix.url = \"github:on-nix/python\";\n    pythonOnNix.inputs.nixpkgs.follows = \"nixpkgs\";\n  };\n  outputs = { self, ... } @ inputs:\n    inputs.flakeUtils.lib.eachSystem [ \"x86_64-linux\" ] (system:\n      let\n        nixpkgs = inputs.nixpkgs.legacyPackages.${system};\n        pythonOnNix = inputs.pythonOnNix.lib.${system};\n\n        # Pick the Python version of your choice:\n        # - `python37Env`: Python 3.7\n        # - `python38Env`: Python 3.8\n        # - `python39Env`: Python 3.9\n        # - `python310Env`: Python 3.10\n        env = pythonOnNix.python39Env {\n          name = \"example\";\n          projects = {\n            awscli = \"1.20.31\";\n            numpy = \"latest\";\n            requests = \"latest\";\n            torch = \"1.9.0\";\n          };\n        };\n        # `env` has two attributes:\n        # - `dev`: The activation script for the Python on Nix environment\n        # - `out`: The raw contents fo the Python site-packages\n      in\n      {\n        packages = rec {\n\n          something = nixpkgs.stdenv.mkDerivation {\n            buildInputs = [ env.dev ];\n            virtualEnvironment = env.out;\n\n            builder = builtins.toFile \"builder.sh\" ''\n              source $stdenv/setup\n\n              set -x\n\n              ls $virtualEnvironment\n              python --version\n              aws --version\n              python -c 'import numpy; print(numpy.__version__)'\n              python -c 'import requests; print(requests.__version__)'\n              python -c 'import torch; print(torch.__version__)'\n\n              touch $out\n\n              set +x\n            '';\n            name = \"something\";\n          };\n\n        };\n      }\n    );\n}\n```\n\nNow just `$ nix -L build .#something` ! :rocket:\n\n```bash\n+ ls /nix/store/...-example-out\n  awscli              colorama  numpy            requests    torch\n  botocore            docutils  pyasn1           rsa         typing-extensions\n  certifi             idna      python-dateutil  s3transfer  urllib3\n  charset-normalizer  jmespath  pyyaml           six\n+ python --version\n  Python 3.9.6\n+ aws --version\n  aws-cli/1.20.31 Python/3.9.6 Linux/5.10.62 botocore/1.21.31\n+ python -c 'import numpy; print(numpy.__version__)'\n  1.21.2\n+ python -c 'import requests; print(requests.__version__)'\n  2.26.0\n+ python -c 'import torch; print(torch.__version__)'\n  1.9.0+cu102\n\n+ touch /nix/store/dcccmxjllgwb9c9j6irp68f1qp4ssxyg-example\n```\n\n# Contributing\n\nAnything you can think of will be appreciated!\n\n# License\n\nCode on this branch is dedicated to the public domain\nvia [The Unlicense](https://unlicense.org/) license.\n\nIn other words you can do anything you want with it.\n\nPlease enjoy! :rocket:\n\n---\n\n[nix]: https://nixos.org/\n[projects]: #list-of-available-projects\n[pypi]: https://pypi.org/\n[python]: https://www.python.org/\n[python_releases]: https://www.python.org/downloads/\n[python_wheels]: https://pythonwheels.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fon-nix%2Fpython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fon-nix%2Fpython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fon-nix%2Fpython/lists"}