-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
211 lines (189 loc) · 6.04 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
{
description = "Nix setup for verification using HOL4, and compilation using CakeML";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
holsrc = {
url = "github:HOL-Theorem-Prover/HOL?rev=56875629a42860effd84a80abd66e63a4c7a4961";
flake = false;
};
cakemlsrc = {
url = "github:cakeml/cakeml?rev=a500b998760b855e6d32428c2e39ce0f69a89131";
flake = false;
};
};
outputs = { self, nixpkgs, holsrc, cakemlsrc }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; overlays = [
(final: prev: {
polyml = prev.polyml.overrideAttrs (attrs: {
configureFlags = [ "--enable-shared" ];
});})
];};
in {
packages.${system} = rec {
hol4 = pkgs.stdenv.mkDerivation {
name = "hol4";
src = holsrc;
buildInputs = (with pkgs; [ polyml graphviz fontconfig ]);
installPhase = ''
chmod --recursive a-w "$out" || true
'';
buildPhase = ''
mkdir -p "$out"
cp --recursive $src/* "$out/"
chmod --recursive +w "$out"
cd $out
export HOLDIR="$(pwd)"
# necessary until including kananaskis-14
substituteInPlace tools/Holmake/Holmake_types.sml \
--replace '"/bin/' '"'
poly < tools/smart-configure.sml
./bin/build --fullbuild
{
cat <<EOF
examples/algorithms
examples/algorithms/unification/triangular/first-order
examples/balanced_bst
examples/bootstrap
examples/Crypto/AES
examples/Crypto/RC6
examples/Crypto/TEA
examples/formal-languages/regular
examples/formal-languages/context-free
examples/formal-languages
examples/fun-op-sem/lprefix_lub
examples/l3-machine-code/common
examples/machine-code/decompiler
examples/machine-code/hoare-triple
examples/machine-code/multiword
examples/miller/miller
EOF
} | while read -r dir; do
echo ":: building HOLDIR/$dir"
cd "$HOLDIR/$dir" && $HOLDIR/bin/Holmake
done
{
cat <<EOF
examples/algorithms
examples/algorithms/unification/triangular/first-order
examples/balanced_bst
examples/bootstrap
examples/Crypto/AES
examples/Crypto/RC6
examples/Crypto/TEA
examples/formal-languages/regular
examples/formal-languages/context-free
examples/formal-languages
examples/fun-op-sem/lprefix_lub
examples/l3-machine-code/common
examples/machine-code/decompiler
examples/machine-code/hoare-triple
examples/machine-code/multiword
examples/miller/miller
EOF
} | while read -r dir; do
echo ":: building HOLDIR/$dir"
cd "$HOLDIR/$dir" && $HOLDIR/bin/Holmake
done
'';
};
cakeml = pkgs.stdenv.mkDerivation {
name = "CakeML";
src = cakemlsrc;
# dependencies gcc, gnumake and glibc are loaded by default
buildInputs = [ hol4 ] ++ (with pkgs; [ gcc gnumake glibc ]);
# glibc with _FORTIFY_SOURCE>0 causes build of basis_ffi.c to fail
hardeningDisable = [ "fortify" ];
buildPhase = ''
mkdir --parents "$out"
cp --recursive $src/* "$out/"
chmod --recursive +w "$out"
cd $out
export HOLDIR="${hol4}"
export CAKEMLDIR="$(pwd)"
{
cat <<EOF
developers
misc
semantics
basis/pure
characteristic
translator
translator/monadic
compiler/parsing
basis
unverified/sexpr-bootstrap
EOF
} | while read -r dir; do
echo ":: building CAKEMLDIR/$dir"
cd "$CAKEMLDIR/$dir" && "$HOLDIR/bin/Holmake" -k
done
{
cat <<EOF
developers
misc
semantics
basis/pure
characteristic
translator
translator/monadic
compiler/parsing
basis
unverified/sexpr-bootstrap
EOF
} | while read -r dir; do
echo ":: building CAKEMLDIR/$dir"
cd "$CAKEMLDIR/$dir" && "$HOLDIR/bin/Holmake" -k
done
'';
installPhase = ''
true
'';
};
cakemlbin = pkgs.stdenv.mkDerivation rec {
name = "cakeml-bin-${version}";
version = "2157";
# https://nixos.wiki/wiki/Packaging/Binaries
src = pkgs.fetchurl {
url = "https://github.com/CakeML/cakeml/releases/download/v${version}/cake-x64-64.tar.gz";
sha256 = "sha256-km5LetIytSVFftWlO0kMEubnVv0jozvWJHz6r30lPLI=";
};
buildInputs = with pkgs; [ gcc gnumake glibc ];
# glibc with _FORTIFY_SOURCE>0 causes build of basis_ffi.c to fail
hardeningDisable = [ "fortify" ];
installPhase = ''
install -m755 -D -t $out cake
install -m555 -D -t $out \
basis_ffi.c Makefile cake-sexpr-32 cake-sexpr-64
'';
meta = with pkgs.lib; {
homepage = "https://cakeml.org";
description = "A verified implementation of ML";
platforms = platforms.linux;
};
};
default = pkgs.stdenv.mkDerivation {
pname = "test nix ci";
version = "1.2.3";
src = self;
buildInputs = [ hol4 cakeml cakemlbin ];
# glibc with _FORTIFY_SOURCE>0 causes build of basis_ffi.c to fail
hardeningDisable = [ "fortify" ];
buildPhase = ''
mkdir --parents "$out"
cp --recursive "$src"/* "$out/"
chmod --recursive +w "$out"
cd $out
export HOLDIR="${hol4}"
export CAKEMLDIR="${cakeml}"
export CAKEDIR="${cakemlbin}"
make
'';
installPhase = ''
true
'';
};
};
};
}