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
.cabalfile(s) andcabal.projectfile (if present). - You get a working "root"
default.nixandshell.nixfor your entire project, and individual "leaf"default.nixandshell.nixfor each subproject. - The "root"
shell.nixincludes 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
nixpkgsfor maximum reproducibility. Thesetupscript by default uses the latestnixpkgs-unstablecommit, but you can use whatever commit you want by editing thenixpkgs.jsonfile that gets created. - All
nix-shells include a Hoogle with the dependencies of that project indexed. This can be configured either inoptions.nixor on the command-line by passing--arg hoogle falsetonix-shell. - You can use configure the version of GHC you use, either in
options.nixor on the command-line by passing--argstr ghc ghc865tonix-shell. - A
config.nixwhich is read and passed tonixpkgs; you can use this to set options likeallowUnfreeorallowBrokenas 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.projectand you want to generatedefault.nixandshell.nixfiles for them.