Haskell Nix template

I’ve been developing Haskell projects using a combination of the following which I really enjoy using,

  • Nix (for reproducible dev environment)
  • Nix Flakes (improved workflow in Nix, especially for pinning)
  • VSCode + haskell-language-server (for IDE support)
  • ormolu for autoformatting
  • Relude as prelude
  • ghcid for quick reloading

So I decided to create a Git template for re-use in future Haskell projects, and thought it may be of interest to others.

The README is self-sufficient in that you should be able to get started on all three platforms (For Windows, WSL2 + the Remote - WSL VSCode extension is required).


This template now works on M1 Mac as well.


The bulk of Nix in this template have recently been moved to a flake-parts module of its own: https://github.com/srid/haskell-flake

1 Like

A small template that demonstrates how to nixify a multi-package Cabal project using nothing but[^1] nixpkgs

Esssentially, pkgs.haskellPackages.extend and shellFor is all you need, in addition to whatever functions provided by pkgs.haskell.lib as appropriate (example).

[^1]: To be fair, the flake.nix uses flake-parts but only for convenience. It is not strictly needed.


haskell-flake now supports multi-package Haskell projects!

See haskell-multi-nix/flake.nix at master · srid/haskell-multi-nix · GitHub for a simple example.

haskell-flake has a documentation site: https://haskell.flake.page/

I plan to write a series of guides on using Nix for Haskell projects over time.

1 Like