flake-parts
Nix module for Haskell development
988a78590c
Flake lock file updates: • Updated input 'haskell-flake': 'github:srid/haskell-flake/5b0857e0b7feec60bf00e075f7859746d52b8564?narHash=sha256-LNbwGgBT5EqfWN7pqYbj71VLLGQJqWkde3ToOhkM5vM%3D' (2024-04-28) → 'github:srid/haskell-flake/d06c68deaed203b6fd172e18fc6cacfee45f748c?narHash=sha256-mHXGbESaMbS8gJ8%2BDtJwgaJLtpGKYAYgXqUzAgf/O70%3D' (2024-05-05) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/5fd8536a9a5932d4ae8de52b7dc08d92041237fc?narHash=sha256-oOUdvPrO8CbupgDSaPou%2BJv6GL%2BuQA2QlE33D7OLzkM%3D' (2024-05-03) → 'github:nixos/nixpkgs/e4e7a43a9db7e22613accfeb1005cca1b2b1ee0d?narHash=sha256-FCi3R1MeS5bVp0M0xTheveP6hhcCYfW/aghSTPebYL4%3D' (2024-05-11) |
||
---|---|---|
.github/workflows | ||
.vscode | ||
dev | ||
doc | ||
example | ||
nix | ||
test | ||
.envrc | ||
.gitignore | ||
CHANGELOG.md | ||
flake.nix | ||
justfile | ||
LICENSE | ||
README.md |
haskell-flake - Manage Haskell projects conveniently with Nix
There are several ways to manage Haskell packages using Nix with varying degrees of integration. haskell-flake
makes Haskell development, packaging and deployment with Nix flakes a lot simpler than other existing approaches. This project is set up as a modern flake-parts
module to integrate easily into other Nix projects and shell development environments in a lightweight and modular way.
To see more background information, guides and best practices, visit https://community.flake.parts/haskell-flake
Caveat: haskell-flake
only supports the Haskell package manager Cabal,
so your project must have a top-level .cabal
file (single package project) or a cabal.project
file
(multi-package project).
Getting started
The minimal changes to your flake.nix
to introduce the haskell-flake
and flake-parts
modules will look similar to:
# file: flake.nix
{
inputs = {
...
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux", ... ];
imports = [
...
inputs.haskell-flake.flakeModule
];
perSystem = { self', system, lib, config, pkgs, ... }: {
haskellProjects.default = {
# basePackages = pkgs.haskellPackages;
# Packages to add on top of `basePackages`, e.g. from Hackage
packages = {
aeson.source = "1.5.0.0" # Hackage version
};
# my-haskell-package development shell configuration
devShell = {
hlsCheck.enable = false;
};
# What should haskell-flake add to flake outputs?
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
};
devShells.default = pkgs.mkShell {
name = "my-haskell-package custom development shell";
inputsFrom = [
...
config.haskellProjects.default.outputs.devShell
];
nativeBuildInputs = with pkgs; [
# other development tools.
];
};
};
};
}
haskell-flake
scans your folder automatically for a .cabal
or cabal.project
file.
In this example an imaginary my-haskell-package.cabal
project is used.
To see in more detail how to use haskell-flake
in a realistic Haskell project
with several other development tools, take a look at
the corresponding Haskell single-package project Nix template and
this Haskell multi-package project Nix example.
Documentation
https://community.flake.parts/haskell-flake
Discussion
Zulip is the primary venue for discussion; we also have Github Discussions enabled.