A flake-parts Nix module for Haskell development
Go to file
Shivaraj B H 5113f700d6
settings: add removeReferencesTo (#225)
This setting helps remove unnecessary dependencies to your haskell package that
bloats up the final closure size

Source: 5623bb3814/nix/removeReferencesTo.nix (L9)


---------

Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com>
Co-authored-by: Sridhar Ratnakumar <srid@srid.ca>
2024-02-13 09:49:51 -05:00
.github/workflows ci: Use latest nixci 2024-02-13 07:27:24 -05:00
.vscode Add dev flake (#179) 2023-07-03 16:56:27 -04:00
dev dev: Disable treefmt check (#230) 2024-02-13 08:52:51 -05:00
doc settings: add removeReferencesTo (#225) 2024-02-13 09:49:51 -05:00
example docs: community.flake.parts host (#209) 2023-11-28 14:51:50 -05:00
nix settings: add removeReferencesTo (#225) 2024-02-13 09:49:51 -05:00
test fix(cabal.project parser): parse the packages ending with eof (#222) 2024-02-06 03:08:48 -05:00
.envrc Add dev flake (#179) 2023-07-03 16:56:27 -04:00
.gitignore Add dev flake (#179) 2023-07-03 16:56:27 -04:00
CHANGELOG.md settings: add removeReferencesTo (#225) 2024-02-13 09:49:51 -05:00
flake.nix Port docs back to Emanote (#217) 2024-01-22 23:30:48 -05:00
LICENSE Initial commit 2022-05-30 09:01:58 -04:00
README.md doc: Flatten index note (#224) 2024-02-09 12:50:52 -05:00
rundoc.sh Add emanote run command to docs script 2023-03-14 11:21:11 -04:00
runtest.sh ci: Jenkins ➡️ self-hosted runners (#218) 2024-01-27 02:35:16 -05:00

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.