A flake-parts Nix module for Haskell development
Go to file
github-actions[bot] 125d72226a chore(example): Update flake.lock
Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8?narHash=sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw%3D' (2024-06-01)
  → 'github:hercules-ci/flake-parts/9227223f6d922fee3c7b190b2cc238a99527bbb7?narHash=sha256-pQMhCCHyQGRzdfAkdJ4cIWiw%2BJNuWsTX7f0ZYSyz0VY%3D' (2024-07-03)
• Updated input 'flake-parts/nixpkgs-lib':
    'eb9ceca17d.tar.gz?narHash=sha256-lIbdfCsf8LMFloheeE6N31%2BBMIeixqyQWbSr2vk79EQ%3D' (2024-06-01)
  → '5daf051448.tar.gz?narHash=sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI%3D' (2024-07-01)
• Updated input 'haskell-flake':
    'github:srid/haskell-flake/dfea80e8a907a7818f11090788f84f1a62985694?narHash=sha256-ytIvs6dq1dD3eicwhmqMyhIDH52DfqhOiCpmJbjBYVI%3D' (2024-06-24)
  → 'github:srid/haskell-flake/64bd0f328e5a424b65aafdde3901b64f4f390b0f?narHash=sha256-MtatlRdAy7eWdgZI8JgW/OmY/aqF%2BSvRucqlsLHzX80%3D' (2024-07-03)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/1e3deb3d8a86a870d925760db1a5adecc64d329d?narHash=sha256-vN5xJAZ4UGREEglh3lfbbkIj%2BMPEYMuqewMn4atZFaQ%3D' (2024-06-27)
  → 'github:nixos/nixpkgs/4284c2b73c8bce4b46a6adf23e16d9e2ec8da4bb?narHash=sha256-i4vJL12/AdyuQuviMMd1Hk2tsGt02hDNhA0Zj1m16N8%3D' (2024-07-05)
2024-07-06 23:01:56 -04:00
.github/workflows chore(ci): Add workflow_dispatch 2024-06-24 10:21:27 -04:00
.vscode Add dev flake (#179) 2023-07-03 16:56:27 -04:00
dev chore: Fix broken link 2024-06-20 16:28:11 -04:00
doc chore(doc): Update flake.lock 2024-07-03 11:22:29 -04:00
example chore(example): Update flake.lock 2024-07-06 23:01:56 -04:00
nix fix: support older nixpkgs 2024-04-25 02:19:06 -04:00
test feat: Add granular settings defaults (#275) 2024-04-20 03:44:10 -04:00
.envrc envrc: reload on dev/flake.nix change 2024-03-27 15:26:59 -04:00
.gitignore Add dev flake (#179) 2023-07-03 16:56:27 -04:00
CHANGELOG.md chore: Tag release 2024-06-24 13:16:27 -04:00
flake.nix feat: Add granular settings defaults (#275) 2024-04-20 03:44:10 -04:00
justfile Nixify rundoc.sh 2024-02-29 17:47:17 -05:00
LICENSE Initial commit 2022-05-30 09:01:58 -04:00
README.md readme: add zulip badge 2024-02-21 12:12:33 -05:00

project chat Harmeless Code of Conduct

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.