-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathkaramel.nix
78 lines (68 loc) · 1.77 KB
/
karamel.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
{
fstar,
ocamlPackages,
removeReferencesTo,
stdenv,
symlinks,
version,
which,
z3,
}: let
pname = "karamel";
propagatedBuildInputs = with ocamlPackages; [
batteries
stdint
ppx_deriving_yojson
zarith
pprint
menhirLib
sedlex
process
fix
wasm
ctypes
visitors
uucp
];
nativeBuildInputs = [fstar removeReferencesTo symlinks which z3] ++ (with ocamlPackages; [ocaml dune_3 findlib menhir]);
in
stdenv.mkDerivation {
inherit version pname propagatedBuildInputs nativeBuildInputs;
src = ./..;
outputs = ["out" "home"];
FSTAR_HOME = fstar;
GIT_REV = version;
configurePhase = "export KRML_HOME=$(pwd)";
enableParallelBuilding = true;
preBuild = "mkdir -p krmllib/hints";
preInstall = "export PREFIX=$out";
postInstall = ''
# OCaml leaves its full store path in produced binaries
# Thus we remove every reference to it
for binary in $out/bin/*
do
remove-references-to -t '${ocamlPackages.ocaml}' $binary
done
symlinks -c $KRML_HOME
cp -r ./. $home
'';
passthru = {
lib = ocamlPackages.buildDunePackage {
GIT_REV = version;
# the Makefile expects `FSTAR_HOME` to be or `fstar.exe` to be
# in PATH, but this is not useful for buulding the library
FSTAR_HOME = "dummy";
inherit version propagatedBuildInputs;
nativeBuildInputs = with ocamlPackages; [menhir];
pname = "krml";
preBuild = ''
# the library is named `krml` rather than `karamel`
mv karamel.opam krml.opam
sed -i '/name krml/a (public_name krml)' lib/dune
make lib/Version.ml lib/AutoConfig.ml
'';
src = ../.;
};
};
dontFixup = true;
}