Nix is a purely functional package manager that allows defining all dependencies for Python projects and applications in a declarative way. It can be used to build environments with exact dependency specifications, create shells with predefined packages, and build applications into immutable outputs along with all dependencies. Nixpkgs contains thousands of pre-defined packages and allows reproducible and isolated builds.
6. Using a Python package may require external software
– Graphviz
– ImageMagick
– LATEX
– NodeJS
– ...
7. Running a Python application may require external services
– PostgreSQL
– memcached
– Redis
– RabbitMQ
– ...
8. ONE DOES NOT SIMPLYONE DOES NOT SIMPLY
pip installpip install
9.
10. What if you could simply define any dependencies in a
hashbang?
#! /usr/bin/env nix-shell
#! nix-shell -i python -p pythonPackages.pillow
11. . . . or define all required dependencies just when calling?
$ nix-shell -p python -p gnuplot -p git --run "python
gitstats input output"→
12. . . . build an environment with any dependencies?
$ nix-build filename.nix -o env
$ ls env/bin
2to3 dvilj4 makeindex pdflatex
afm2pl dvilj4l makejvf pdfmex
afm2tfm dvilj6 mendex pdftex
...
ctangle gftopk otfinfo python
...
13. . . . enter into a shell with any dependencies?
$ nix-shell filename.nix
$ which latex
/nix/store/.../bin/latex
$ which python
/nix/store/.../bin/python
$ exit
14. . . . easily build an app with any dependencies into a single
container?
FROM scratch
ADD myapp.nix.tar.gz /
EXPOSE 8080
ENTRYPOINT ["/app/bin/python3"]
15.
16. Nix – the purely functional package manager
– Functional DSL for building stuff
– Builds named by their expression hash
– Builds isolated and reproducible
– Build results immutable and shareable
– Single or multi-user installation
– Garbage collection on request
– Tools for development and distribution