haskell-flake you must first install Nix.
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
my-package. Follow the comments along the
flake.nix to make any necessary changes to the project configuration.
To create a new Haskell project, instead, run:
mkdir example && cd ./example
nix flake init -t github:srid/haskell-flake#example
You may also use https://github.com/srid/haskell-template which already uses
haskell-flake along with other opinionated defaults.
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.projectfile (via haskell-parsers)
- Parse executables from
- Modular interface to
- Composition of dependency overrides, and other project settings, via [[modules]]