flake-parts
Nix module for Haskell development
Flake lock file updates: • Updated input 'cfp': 'github:flake-parts/community.flake.parts/1b2a974c8c48a11e5fde624940cc44e0cd8368e3?narHash=sha256-JKSm6ZRNKHzNbRDbkXu0d9d27LE1nDLDdI/arnVmTdU%3D' (2024-04-26) → 'github:flake-parts/community.flake.parts/b056f7669c63a31c783e58730ea4a61a11c8bcf2?narHash=sha256-tPio9JaMC5kGZc5Ng5s2Ajw%2BhZ5EMSg6VMtHmdfNDSw%3D' (2024-04-30) • Updated input 'cfp/haskell-flake': 'github:srid/haskell-flake/2ee7904390ce78a81d0f66fcc98bf4c32d128d33?narHash=sha256-R2k/UG5XtyTtmezRs0HZZ9MlvhWXtkyHR%2BngEAWrtZI%3D' (2024-04-25) → 'github:srid/haskell-flake/5b0857e0b7feec60bf00e075f7859746d52b8564?narHash=sha256-LNbwGgBT5EqfWN7pqYbj71VLLGQJqWkde3ToOhkM5vM%3D' (2024-04-28) • Updated input 'cfp/services-flake': 'github:juspay/services-flake/dbb93b39ce83530e6f86daa46c671055f224816d?narHash=sha256-%2BgszdjbWWt5m%2B77weTSk9l67Z4cUAmDLp%2BucjJViEpc%3D' (2024-04-26) → 'github:juspay/services-flake/8d64a960367e07f7d21fa890f77f56daabc5d8bd?narHash=sha256-kchvJP4Ih%2BZ/YG8Sd6CvbNMss9MCDlrt4sgTKL5czpY%3D' (2024-04-30) • Updated input 'flake-parts-website': 'github:hercules-ci/flake.parts-website/a29d5114464ca6f0c58f1ed6a3c266fdd3cea97a?narHash=sha256-RIHQfDQjD5CciYb0TPRJ%2BdLnfSTqIHRKtUo5O6iKXuw%3D' (2024-04-27) → 'github:hercules-ci/flake.parts-website/2b4a2f1ee178f853cdd0f78fe6272e92a5d7dc05?narHash=sha256-kP6S3bUBQHdTKEzz4HLKf5cw2YTWz9E%2Bpr4nfzuxqD4%3D' (2024-05-04) • Updated input 'flake-parts-website/agenix-shell': 'github:aciceri/agenix-shell/eee60a60173bc3401e8dcc11469dce488a7e2b0c?narHash=sha256-9Oxc%2BPA/Es/eRn6%2BdQx/DnyohrmmbvHrPxcfeSuA884%3D' (2024-04-18) → 'github:aciceri/agenix-shell/884a3318aa661e237816e35b46dd014775498f19?narHash=sha256-vSHHsSPHf1MElw/dUM01u13tCO8LkM0N/pnSK9sIu2I%3D' (2024-05-02) • Updated input 'flake-parts-website/nix-cargo-integration': 'github:yusdacra/nix-cargo-integration/370d0ff9f97edb363f08af17dadaed3928ee1942?narHash=sha256-5Xl7tJjG1GBTT8evOXehNAIZoZ8W5EtLlqiYjMPNUlI%3D' (2024-04-27) → 'github:yusdacra/nix-cargo-integration/197a25e95fc0b836b428d408fdc5904ed728d234?narHash=sha256-InxRQ77/3dAkarMBf10LchvMJ1a%2Bn%2Bc6esfaiRMpnNI%3D' (2024-05-04) • Updated input 'flake-parts-website/nix-cargo-integration/parts': 'github:hercules-ci/flake-parts/9126214d0a59633752a136528f5f3b9aa8565b7d?narHash=sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm%2BGpZNw%3D' (2024-04-01) → 'github:hercules-ci/flake-parts/e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e?narHash=sha256-yzcRNDoyVP7%2BSCNX0wmuDju1NUCt8Dz9%2BlyUXEI0dbI%3D' (2024-05-02) • Updated input 'flake-parts-website/nix-cargo-integration/rust-overlay': 'github:oxalica/rust-overlay/2a42c742ab04b61d9b2f1edf392842cf9f27ebfd?narHash=sha256-044xbpBszupqN3nl/CGOCJtTQ4O6Aca81mJpX45i8/I%3D' (2024-04-26) → 'github:oxalica/rust-overlay/b37d96b614c38922674fd8d81ebc2fe807667a5b?narHash=sha256-UxFPoIskGHp1lFetK55jsuCvagqLXVE9pD%2BIjWQUWiY%3D' (2024-05-04) • Updated input 'flake-parts-website/pre-commit-hooks-nix': 'github:cachix/pre-commit-hooks.nix/6fb82e44254d6a0ece014ec423cb62d92435336f?narHash=sha256-RWFafuSb5nkWGu8dDbW7gVb8FOQOPqmX/9MlxUUDguw%3D' (2024-04-24) → 'github:cachix/pre-commit-hooks.nix/2849da033884f54822af194400f8dff435ada242?narHash=sha256-q//cgb52vv81uOuwz1LaXElp3XAe1TqrABXODAEF6Sk%3D' (2024-04-30) • Updated input 'flake-parts-website/std': 'github:divnix/std/37cbf2f9cadfdbf0a96d22881d8aa383d5bfdd67?narHash=sha256-MdosbJld9vlbgXJIitH/v5D2OF%2BSQdMKTj9B4bgAy9k%3D' (2024-03-30) → 'github:divnix/std/23a1aba8256b42b00ada359d561139c8f2cc5445?narHash=sha256-K0m67SmxjnvAdoH4HUK8EbCwB1paYrvix9R6dy%2B8%2BqI%3D' (2024-04-30) • Updated input 'haskell-flake': 'github:srid/haskell-flake/2ee7904390ce78a81d0f66fcc98bf4c32d128d33?narHash=sha256-R2k/UG5XtyTtmezRs0HZZ9MlvhWXtkyHR%2BngEAWrtZI%3D' (2024-04-25) → 'github:srid/haskell-flake/5b0857e0b7feec60bf00e075f7859746d52b8564?narHash=sha256-LNbwGgBT5EqfWN7pqYbj71VLLGQJqWkde3ToOhkM5vM%3D' (2024-04-28) |
||
---|---|---|
.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
![](/srid/haskell-flake/media/commit/302ec46504b4dd8eaa5ba11a5934afce49c2a39e/doc/haskell-flake.webp)
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.