Stacklock2nix: easily build Stack-based Haskell projects with Nix

A few weeks ago I put together a Nix library stacklock2nix. It enables you to easily build a Stack-based Haskell project with the Haskell infrastructure from Nixpkgs:

stacklock2nix is an alternative to haskell.nix for projects that:

  • you want to build with the Haskell infrastructure in Nixpkgs
  • you already have a stack.yaml.lock file, and want to generate a package set with package versions based off the stack.yaml.lock
  • you don’t need all the functionality provided by haskell.nix

I’m using stacklock2nix to build a sizeable Haskell project at work, and it seems to be working relatively smoothly. I’ve also written a series of blog posts about packaging various Haskell projects using stacklock2nix. Each blog post contains some example code using stacklock2nix:

The stacklock2nix repo also has an example Haskell project that can build with stacklock2nix. Here’s a flake.nix from that project that you can use to get an idea of stacklock2nix:

Additional documentation can be found in the stacklock2nix README.

I also posted about stacklock2nix on the NixOS Discourse, and there was some interesting discussion there.

5 Likes