A `flake-parts` Nix module for Haskell development
239
stars
507
commits
Nix
primary language
Sep 6, 2026
updated
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 a lot simpler than other existing approaches. It works with plain Nix (no flakes), Nix flakes, or as a flake-parts module—choose whichever fits your project.
To see more background information, guides and best practices, visit https://haskell.nixos.asia
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).
The guide below uses flake-parts; for other approaches see standalone usage.
The minimal changes to your flake.nix to introduce haskell-flake with flake-parts 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.
Please post questions & ideas in Github Discussions.
Nix
93.2%
Shell
4.5%
Haskell
1.9%
A `flake-parts` Nix module for Haskell development
239
stars
507
commits
Nix
primary language
Sep 6, 2026
updated
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 a lot simpler than other existing approaches. It works with plain Nix (no flakes), Nix flakes, or as a flake-parts module—choose whichever fits your project.
To see more background information, guides and best practices, visit https://haskell.nixos.asia
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).
The guide below uses flake-parts; for other approaches see standalone usage.
The minimal changes to your flake.nix to introduce haskell-flake with flake-parts 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.
Please post questions & ideas in Github Discussions.
Nix
93.2%
Shell
4.5%
Haskell
1.9%