functor.tokyo Open in urlscan Pro
128.199.131.160  Public Scan

URL: https://functor.tokyo/blog/2022-12-15-stacklock2nix
Submission: On January 05 via manual from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

category theory and other fun things

 * Home
 * About
 * Projects
 * Blog

--------------------------------------------------------------------------------

stacklock2nix

2022-12-15

AddThis Sharing Buttons
Share to FacebookFacebookShare to TwitterTwitterShare to PrintPrintShare to
EmailEmailShare to MoreAddThis

For a while now I've wanted a way to use Nix to build a Haskell package that has
a stack.yaml file. The go-to method in the Haskell community is to use
haskell.nix, but haskell.nix has a few downsides1:

 * Evaluation can take quite a while, and building your project without using
   the IOHK cache can take a very long time.
 * haskell.nix is quite complicated. It can be hard to figure out problems and
   fix bugs.
 * It is completely separate from the Haskell infrastructure in Nixpkgs.

I decided to write a Nix library called stacklock2nix. It generates a
Nixpkgs-compatible Haskell overlay from a stack.yaml and stack.yaml.lock file.
This allows you to easily build a Haskell project with Nix (as long as you have
a stack.yaml and stack.yaml.lock file). It allows you to use your stack.yaml
file as a single-source-of-truth for Haskell dependency versions2.

You can find usage instructions, as well as two example projects in the README.

I've decided to do a series of blog posts where I use stacklock2nix to package
various Haskell projects. Check out each one for a realistic example of using
stacklock2nix:

 1. PureScript
    
    This post introduces an easy way to build a straight-forward Haskell project
    with stacklock2nix. This is good for beginners.

 2. Dhall
    
    This post introduces an advanced way to build a Haskell project with
    multiple packages. This is good for developers who need ultimate
    flexibility.

 3. Pandoc
    
    This post is similar to the post about building the PureScript compiler, but
    it sets up Pandoc to be statically linked. This would be a good example to
    follow for people that want to distribute fully statically-linked Haskell
    binaries.


FOOTNOTES

--------------------------------------------------------------------------------

 1. haskell.nix of course has a bunch of good points as well.↩︎

 2. As opposed to manually keeping dependency versions in sync between
    stack.yaml and your Nix code.↩︎

tags: haskell, nixos

AddThis Sharing Buttons
Share to FacebookFacebookShare to TwitterTwitterShare to PrintPrintShare to
EmailEmailShare to MoreAddThis




© 2014-2020 Dennis Gosnell