-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
231 lines (209 loc) · 7.22 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
{
description = "Pacer: A utility for runners.";
inputs = {
# nix
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-hs-utils.url = "github:tbidne/nix-hs-utils";
# haskell
algebra-simple = {
url = "github:tbidne/algebra-simple";
inputs.flake-parts.follows = "flake-parts";
inputs.nix-hs-utils.follows = "nix-hs-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
bounds = {
url = "github:tbidne/bounds";
inputs.flake-parts.follows = "flake-parts";
inputs.nix-hs-utils.follows = "nix-hs-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
effectful-libs = {
url = "github:tbidne/effectful-libs";
inputs.flake-parts.follows = "flake-parts";
inputs.nix-hs-utils.follows = "nix-hs-utils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.algebra-simple.follows = "algebra-simple";
inputs.bounds.follows = "bounds";
inputs.exception-utils.follows = "exception-utils";
inputs.fs-utils.follows = "fs-utils";
};
exception-utils = {
url = "github:tbidne/exception-utils";
inputs.flake-parts.follows = "flake-parts";
inputs.nix-hs-utils.follows = "nix-hs-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
fs-utils = {
url = "github:tbidne/fs-utils";
inputs.flake-parts.follows = "flake-parts";
inputs.nix-hs-utils.follows = "nix-hs-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
relative-time = {
url = "github:tbidne/relative-time";
inputs.flake-parts.follows = "flake-parts";
inputs.nix-hs-utils.follows = "nix-hs-utils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.algebra-simple.follows = "algebra-simple";
inputs.bounds.follows = "bounds";
};
smart-math = {
url = "github:tbidne/smart-math";
inputs.flake-parts.follows = "flake-parts";
inputs.nix-hs-utils.follows = "nix-hs-utils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.algebra-simple.follows = "algebra-simple";
inputs.bounds.follows = "bounds";
};
};
outputs =
inputs@{
flake-parts,
nixpkgs,
nix-hs-utils,
self,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
perSystem =
{ pkgs, ... }:
let
hlib = pkgs.haskell.lib;
ghc-version = "ghc9101";
compiler = pkgs.haskell.packages."${ghc-version}".override {
overrides =
final: prev:
{
effectful-core = prev.effectful-core_2_5_1_0;
effectful = prev.effectful_2_5_1_0;
megaparsec = prev.megaparsec_9_7_0;
path = hlib.dontCheck prev.path_0_9_6;
regression-simple = hlib.doJailbreak prev.regression-simple;
tasty-bench = prev.tasty-bench_0_4;
tasty-bench-fit = prev.tasty-bench-fit_0_1_1;
}
// nix-hs-utils.mkLibs inputs final [
"algebra-simple"
"bounds"
"exception-utils"
"fs-utils"
"smart-math"
"relative-time"
]
// nix-hs-utils.mkRelLibs "${inputs.effectful-libs}/lib" final [
"concurrent-effectful"
"effectful-utils"
"fs-effectful"
"ioref-effectful"
"logger-effectful"
"logger-ns-effectful"
"optparse-effectful"
"terminal-effectful"
"time-effectful"
"typed-process-dynamic-effectful"
];
};
compilerPkgs = {
inherit compiler pkgs;
};
pkgsMkDrv = {
inherit pkgs;
mkDrv = false;
};
node = pkgs.nodejs_23;
mkPkg =
returnShellEnv:
nix-hs-utils.mkHaskellPkg {
inherit compiler pkgs returnShellEnv;
name = "pacer";
root = ./.;
modifier =
drv:
drv.overrideAttrs (oldAttrs: {
# We have makeWrapper so wrapProgram is available in
# postFixup. Git is needed to run the tests (git diff).
nativeBuildInputs = oldAttrs.nativeBuildInputs or [ ] ++ [
pkgs.git
pkgs.makeWrapper
];
# This is apparently unnecessary, but knowing what version of
# node pacer is using could be helpful.
installPhase =
oldAttrs.installPhase
+ ''
ln -s ${node.out}/bin/npm $out/bin/npm
'';
postFixup = ''
wrapProgram $out/bin/pacer --prefix PATH : ${pkgs.lib.makeBinPath webDeps}
'';
});
# TODO: Once hlint is back to working with our GHC we can
# use nix-hs-utils.mkDevTools ++ webDeps.
devTools = [
(hlib.dontCheck compiler.cabal-fmt)
(hlib.dontCheck compiler.haskell-language-server)
pkgs.nixfmt-rfc-style
] ++ webDeps;
};
stack-wrapped = pkgs.symlinkJoin {
name = "stack";
paths = [ pkgs.stack ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/stack --add-flags "--no-nix --system-ghc"
'';
};
webDeps = [ node ];
in
{
packages.default = mkPkg false;
devShells = {
default = mkPkg true;
# Blank shell intended to be used with --unset PATH, to test that
# we are correctly bundling node dep (default github image has
# node, but we want to ensure we are using __our__ dep).
ci = pkgs.mkShell {
buildInputs = [ ];
};
stack = pkgs.mkShell {
buildInputs = [
compiler.ghc
pkgs.zlib
stack-wrapped
];
};
};
apps = {
format = nix-hs-utils.mergeApps {
apps = [
(nix-hs-utils.format (compilerPkgs // pkgsMkDrv))
({
inherit pkgs;
name = "format";
text = "prettier -w -- **/*html **/*js **/*json **/*ts **/*yaml";
runtimeInputs = [ pkgs.nodePackages.prettier ];
})
];
};
lint = nix-hs-utils.mergeApps {
apps = [
# TODO: We require GHC 9.10+ since we need filepath >= 1.5,
# but hlint is sadly not compatible yet. Hence it is disabled
# for now.
#
#(nix-hs-utils.lint (compilerPkgs // pkgsMkDrv))
(nix-hs-utils.lint-yaml pkgsMkDrv)
];
};
#lint-refactor = nix-hs-utils.lint-refactor compilerPkgs;
};
};
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
};
}