There are many guides and tools out there for using Nix to build Haskell projects, but none of them are Invented Here.
My one can be used as follows:
git submodule add https://github.com/duairc/nix
nix/setup
- Simple setup.
- Zero maintenance; all derivations are built dynamically from
.cabal
file(s) andcabal.project
file (if present). - You get a working "root"
default.nix
andshell.nix
for your entire project, and individual "leaf"default.nix
andshell.nix
for each subproject. - The "root"
shell.nix
includes the transitive build-dependencies of all subprojects, minus the subprojects themselves. This allowscabal
's to do most of the work when you're doing incremental development across multiple subprojects at a time. - It uses a pinned
nixpkgs
for maximum reproducibility. Thesetup
script by default uses the latestnixpkgs-unstable
commit, but you can use whatever commit you want by editing thenixpkgs.json
file that gets created. - All
nix-shell
s include a Hoogle with the dependencies of that project indexed. This can be configured either inoptions.nix
or on the command-line by passing--arg hoogle false
tonix-shell
. - You can use configure the version of GHC you use, either in
options.nix
or on the command-line by passing--argstr ghc ghc865
tonix-shell
. - A
config.nix
which is read and passed tonixpkgs
; you can use this to set options likeallowUnfree
orallowBroken
as required. - An
overrides.nix
, where you can can say things likegeneric-lens = dontCheck super.generic-lens_1_2_0_1
. - The setup script is idempotent, it won't clobber any changes you've made. However you might want to run it again if you add new packages to your
cabal.project
and you want to generatedefault.nix
andshell.nix
files for them.