What do you do when your python project has dependencies beyond Python? Nix is a "purely functional" package manager, which can also be used like "virtualenv", but for everything. I would cover single user installation of Nix package manager on Linux or Mac, defining Nix based development environments, generating Nix expressions for large Python projects using buildout, and finally, building minimal Docker images from scratch by using those generated expressions.
Using a Python package may require external software
Running a Python application may require external services
ONE DOES NOT SIMPLYONE DOES NOT SIMPLY
pip installpip install
What if you could simply deﬁne any dependencies in a
#! /usr/bin/env nix-shell
#! nix-shell -i python -p pythonPackages.pillow
. . . or deﬁne all required dependencies just when calling?
$ nix-shell -p python -p gnuplot -p git --run "python
gitstats input output"→
. . . 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
. . . enter into a shell with any dependencies?
$ nix-shell filename.nix
$ which latex
$ which python
. . . easily build an app with any dependencies into a single
ADD myapp.nix.tar.gz /
Nix – the purely functional package manager
– Functional DSL for building stuﬀ
– 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