I recently learned of Nix, which bills itself
as a “purely functional package manager.” It tries to keep things as
self-contained as possible, installing each package into a separate
directory in its store. Nix is the basis for a Linux distribution
called NixOS, but can also be installed standalone.
Nix has great benefits for Haskell development. Due to its insistence
on isolation and purity, different versions of packages can be swapped
in and out as needed, neatly avoiding “Cabal hell” and the need for
sandboxes. As much as possible, the package manager reuses compiled
versions of dependencies, greatly speeding up the process after the
first time.
One of the great motivations for using Nix to develop Haskell was the
ease with which I can swap in profiling libraries (see
this blog post
for info). Another is the availability of binary caches for many of
the other packages on which Haskell packages depend.
Cabal itself might eventually adopt the kind of hermetic builds Nix offers;
however, Nix works quite well already for this purpose.
I found Pavel Kogan’s post on Haskell development with Nix to be quite instructive.
In this post, I hope to provide some tips for using Nix for Haskell development, specifically on Mac OS X 10.10 (Yosemite).