-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
88 lines (88 loc) · 3.05 KB
/
flake.nix
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
description = "advent-of-code";
inputs = {
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, haskellNix }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
haskellNix.overlay
(final: prev:
{
advent-of-code = {
reflections = prev.callPackage ./reflections { };
benchmarks = prev.callPackage ./bench-results { };
site = prev.callPackage ./site { };
project = prev.haskell-nix.project'
{
name = "advent-of-code";
src = ./.;
compiler-nix-name = "ghc982";
shell = {
withHoogle = false;
buildInputs = [ format-haskell ];
tools = {
cabal = { };
hlint = { };
haskell-language-server = { };
fourmolu = { };
};
};
};
};
}
)
];
pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
advent-of-code-project = pkgs.advent-of-code.project;
inherit (advent-of-code-project.hsPkgs) advent-of-code;
format-haskell =
pkgs.writeShellApplication {
name = "format-haskell";
runtimeInputs = [ (advent-of-code-project.tool "fourmolu" { }) pkgs.haskellPackages.cabal-fmt ];
text = ''
# shellcheck disable=SC2046
fourmolu --mode inplace $(git ls-files 'haskell/*.hs')
cabal-fmt -i advent-of-code.cabal
'';
};
in
{
packages = advent-of-code.components.exes //
{
inherit (pkgs.advent-of-code.site) site;
default = advent-of-code.components.exes.aoc2024;
};
devShells.default = advent-of-code-project.shell;
legacyPackages = pkgs;
apps =
(pkgs.lib.concatMapAttrs
(n: bs: {
"generate-benches-${n}" = {
type = "app";
program = pkgs.lib.getExe bs.generate-benches;
};
})
pkgs.advent-of-code.benchmarks)
//
{
format =
let
app = pkgs.writeShellApplication {
name = "format-haskell";
runtimeInputs = [ (advent-of-code-project.tool "fourmolu" { }) pkgs.haskellPackages.cabal-fmt ];
text = ''
# shellcheck disable=SC2046
fourmolu --mode inplace $(git ls-files '**.hs')
cabal-fmt -i advent-of-code.cabal
'';
};
in
{ type = "app"; program = pkgs.lib.getExe app; };
};
}
);
}