/nix-flake-python-example

Example of a nix flake for a Python project

Primary LanguageNixMIT LicenseMIT

Nix Flake Python Example

TODO

  • Checks:
    • black
    • flake8
    • isort
    • mypy
    • pytest

Requires

  • nix
  • direnv

Or without nix using virtualenv:

  • python39
  • virtualenv

Usage

Run:

nix run . -- --example foo --example bar

Shell:

nix develop

Shell using direnv:

direnv allow .

Run from shell:

python src/mypackage/__init__py --example foo --example bar

Build and run prod:

nix build
./result/bin/mypackage

Usage without Nix using virtualenv

Setup:

source ./scripts/venv

Run:

mypackage

Setup with fresh virtualenv:

source ./scripts/venv true

Update

Update flake, rebuild requirements.txt and requirements-dev.txt:

./scripts/update