Getting Started

Before using haskell-flake you must first install Nix.

Existing projects

To use haskell-flake in an existing Haskell project, run:

nix flake init -t github:srid/haskell-flake

Open the generated flake.nix and change self'.packages.example to use your package name. For example, if your package is named my-package (with a my-package.cabal file), change example to my-package. Follow the comments along the flake.nix to make any necessary changes to the project configuration.

New projects

To create a new Haskell project, instead, run:

mkdir example && cd ./example
nix flake init -t github:srid/haskell-flake#example

Template

You may also use https://github.com/srid/haskell-template which already uses haskell-flake along with other opinionated defaults.

Under the hood

Under the hood
Under the hood

See this tutorial to understand what it takes to package a Haskell application without haskell-flake.

When nixifying a Haskell project without flake-parts (thus without haskell-flake) you would generally use the raw Haskell infrastructure from nixpkgs. haskell-flake uses these functions, while exposing a simpler modular API on top: your flake.nix becomes more declarative and less imperative.

In addition, compared to using plain nixpkgs, haskell-flake supports:

  • Auto-detection of local packages based on cabal.project file (via haskell-parsers)
  • Parse executables from .cabal file
  • Modular interface to pkgs.haskell.lib.compose.* (via packages and settings submodules)
  • Composition of dependency overrides, and other project settings, via Project modules

See Getting Started for getting started with haskell-flake.

Next steps

Visit Guide for more details, and Reference for module options.

Links to this page