-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
325 lines (294 loc) · 9.94 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
{
description = "Example JavaScript development environment for Zero to Nix";
# Flake inputs
inputs = {
nixpkgs.url = "nixpkgs-unstable"; # also valid: "nixpkgs"
ocaml-overlay = {
url = "github:nix-ocaml/nix-overlays";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# Flake outputs
outputs =
{
self,
nixpkgs,
flake-parts,
ocaml-overlay,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
perSystem =
{
config,
self',
inputs',
pkgs,
system,
...
}:
let
jj_tui =
pkgs: ocamlPackages: profile:
let
notty-mine = ocamlPackages.notty.overrideAttrs (old: {
src = ./forks/notty/.;
});
picos_src = pkgs.fetchFromGitHub {
owner = "ocaml-multicore";
repo = "picos";
rev = "1ba3357ec7ca56b9bbeb251904636e3453ff2c32";
sha256 = "sha256-I0PFesFeZ+7H0uXDoC4LNltef5buuKeO2THyq0VBg/A=";
};
picos = ocamlPackages.buildDunePackage {
pname = "picos";
version = "0.5.0";
duneVersion = "3";
src = picos_src;
buildInputs = with ocamlPackages; [
backoff
thread-local-storage
];
strictDeps = true;
};
picos_std = ocamlPackages.buildDunePackage {
pname = "picos_std";
version = "0.5.0";
duneVersion = "3";
src = picos_src;
buildInputs = with ocamlPackages; [
picos
picos_aux
backoff
thread-local-storage
multicore-magic
];
strictDeps = true;
};
picos_aux = ocamlPackages.buildDunePackage {
pname = "picos_aux";
version = "0.5.0";
duneVersion = "3";
src = picos_src;
buildInputs = with ocamlPackages; [
backoff
multicore-magic
];
strictDeps = true;
};
picos_mux = ocamlPackages.buildDunePackage {
pname = "picos_mux";
version = "0.5.0";
duneVersion = "3";
src = picos_src;
buildInputs = with ocamlPackages; [
picos
picos_aux
picos_std
backoff
multicore-magic
thread-local-storage
psq
];
strictDeps = true;
};
picos_io = ocamlPackages.buildDunePackage {
pname = "picos_io";
version = "0.5.0";
duneVersion = "3";
src = picos_src;
buildInputs = with ocamlPackages; [
picos
picos_aux
picos_std
picos_mux
backoff
mtime
multicore-magic
psq
thread-local-storage
];
strictDeps = true;
};
picos_mux_with_io = ocamlPackages.buildDunePackage {
pname = "picos_mux";
version = "0.5.0";
duneVersion = "3";
src = picos_src;
buildInputs =
with ocamlPackages;
picos_io.buildInputs
++ [
picos
picos_aux
picos_std
picos_io
backoff
multicore-magic
thread-local-storage
];
strictDeps = true;
};
signal = ocamlPackages.buildDunePackage {
pname = "signal";
version = "0.4.2";
duneVersion = "3";
src = pkgs.fetchFromGitHub {
owner = "rizo";
repo = "signal";
rev = "704fefe7cd7b59e234a51bb470c7a3254468b5a8";
sha256 = "sha256-AcphzD/4rrWnsVB5ebXzdthQ1Rrw3xXkv4n5ZHosoz0=";
};
buildInputs = with ocamlPackages; [
];
strictDeps = true;
};
lwd = ocamlPackages.buildDunePackage {
pname = "lwd";
version = "0.1.0";
duneVersion = "3";
src = pkgs.fetchFromGitHub {
owner = "faldor20";
repo = "lwd";
rev = "c19bc2fd55c2de977cdd283458ce06402b08febe";
sha256 = "sha256-8QwDzRgffA4wnE9vWLpLfy9MdQ5Yc8wBF5jgRamGMfA=";
};
buildInputs = with ocamlPackages; [ seq ];
strictDeps = true;
};
nottui =
let
pname = "nottui";
in
ocamlPackages.buildDunePackage {
pname = "nottui";
version = "dev";
duneVersion = "3";
src = ./forks/nottui/.;
buildInputs = with ocamlPackages; [
logs
signal
lwd
notty-mine
seq
];
buildPhase = ''
runHook preBuild
rm -rf ./tutorial
dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
'';
checkPhase = ''
runHook preCheck
dune runtest -p ${pname}''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postCheck
'';
installPhase = ''
runHook preInstall
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname}
runHook postInstall
'';
strictDeps = true;
};
jj_tui_build_pkgs =
picos.buildInputs
++ picos_std.buildInputs
++ picos_aux.buildInputs
++ [
lwd
notty-mine
nottui
picos
picos_std
picos_io
picos_mux_with_io
picos_aux
signal
ocamlPackages.logs
ocamlPackages.logs-ppx
ocamlPackages.ppx_deriving
ocamlPackages.mtime
ocamlPackages.multicore-magic
ocamlPackages.psq
ocamlPackages.thread-local-storage
ocamlPackages.spawn
ocamlPackages.parsexp
ocamlPackages.stdio
ocamlPackages.base
ocamlPackages.angstrom
ocamlPackages.ppx_expect
ocamlPackages.uutf
# ocamlPackages.parsexp
# Ocaml package dependencies needed to build go here.
];
jj_tui =
let
pname = "jj_tui";
in
ocamlPackages.buildDunePackage {
pname = pname;
version = "0.1.0";
duneVersion = "3";
src = ./.;
buildInputs = jj_tui_build_pkgs;
buildPhase = ''
runHook preBuild
dune build -p ${pname} --profile ${profile} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
'';
checkPhase = ''
runHook preCheck
dune runtest -p ${pname}--profile ${profile} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postCheck
'';
installPhase = ''
runHook preInstall
dune install --profile ${profile} --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname}
runHook postInstall
'';
strictDeps = true;
};
in
{
jj_tui = jj_tui;
jj_tui_build_pkgs = jj_tui_build_pkgs;
};
# OCaml packages available on nixpkgs
ocamlPackages = pkgs.ocaml-ng.ocamlPackages_5_1;
inherit (pkgs) mkShell lib;
in
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ ocaml-overlay.overlays.default ];
};
packages = {
default = (jj_tui pkgs ocamlPackages "release").jj_tui; # Development environment output
static =
(jj_tui pkgs.pkgsCross.musl64 pkgs.pkgsCross.musl64.ocaml-ng.ocamlPackages_5_1 "static").jj_tui; # Development environment output
};
devShells = {
default = mkShell.override { stdenv = pkgs.gccStdenv; } {
buildInputs = with ocamlPackages; [
dune_3
ocaml
utop
ocamlformat
];
inputsFrom = [ self'.packages.default ];
packages = builtins.attrValues {
inherit (pkgs) gcc pkg-config;
inherit (ocamlPackages) ocaml-lsp ocamlformat-rpc-lib;
};
};
};
};
};
}