📦 juspay / haskell-incremental-build-template

📄 README.md · 37 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37# haskell-incremental-build-template

> [!IMPORTANT]
> This minimal template focuses solely on incremental Haskell build configuration with Nix.
> For a more batteries-included Haskell Nix template, combine it with <https://github.com/srid/haskell-template>

> [!IMPORTANT]
> Requires GHC >= 9.4

A template for incremental Haskell builds using Nix, leveraging [nixpkgs’s Haskell incremental build system](https://github.com/NixOS/nixpkgs/blob/30a7bc1176cd9cd066cd75b9339872fa985a6379/doc/languages-frameworks/haskell.section.md?plain=1#L469-L515) and [haskell-flake]

## Getting Started

For an existing Haskell project already using [haskell-flake], integrate this template by:
- Add the `prev` flake input (see [flake.nix](./flake.nix)).

https://github.com/juspay/haskell-incremental-build-template/blob/7432331400f27924d827fbf81de5140c1fa0052c/flake.nix#L10-L14

- Include settings from [haskell.nix](./nix/modules/flake/haskell.nix):

https://github.com/juspay/haskell-incremental-build-template/blob/7432331400f27924d827fbf81de5140c1fa0052c/nix/modules/flake/haskell.nix#L20-L32

- Use [Find Latest Cached Commit](./.github/actions/find-latest-cached-commit) action to find the commit hash with cached build artifacts.

https://github.com/juspay/haskell-incremental-build-template/blob/efd179a97b078634db3f124e862260d3acc35499/.github/workflows/ci.yaml#L30-L48

[haskell-flake]: https://github.com/srid/haskell-flake

## Quick Trial

- Clone the repository: `git clone https://github.com/juspay/haskell-incremental-build-template && cd haskell-incremental-build-template`
- Perform a full build: `nix build .#default -L`
  - This builds both `Example.hs` and `Main.hs` modules.
- Add a newline to `Main.hs` to simulate a change: `echo >> src/Main.hs`
- Perform an incremental build: `nix build .#default --override-input prev github:juspay/haskell-incremental-build-template -L`
  - Only `Main.hs` is rebuilt.