This is a fully-fledged python project controlled by the uv package manager.
Firstly there's the main library defined in the pyproject.yaml and in the
nix_python_uv folder. There's some scripts, tests, and a few examples of
dependencies.
In the Nix setup we define some the build environment, tests, code formatters, and a docker image with the entrypoint ready to run.
python
...
>>> import pandasnix run .> hello
Hello, world!
> some_script
Hello, world!
Hello, other world!nix build .#docker-image
./result < docker load
docker run nix-python-uv-helloYou can run the tests with pytest:
pytestOr, with nix flake check
nix flake checkNote
Running tests like this with Nix is a bit subtle; if the tests are simple; i.e. "pure"; that is, they don't require external dependencies, then they will work.
nix fmtNote
nix fmt only formats files that are changed; not all files in the
repo. For that, run ruff format directly.
uv add numpy- Each time you add a new dependency you need to reload the devShell. I have a
shell alias,
alias rr="direnv reload"for this purpose.
For the most part, if you simply make changes with uv this should "Just
Work". There will be some busywork if some of the Python dependencies aren't
perfectly configured; but all of that can be addressed.
To add a new package, just add it next to pkgs.uv in
nix/outputs.nix in the devShells package statement.