-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
303 lines (266 loc) · 9.58 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
{
description = "atlas";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.11";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
examples = {
url = "github:lorenzleutgeb/atlas-examples/v0.2.4";
flake = false;
};
gradle2nix = {
url = "github:lorenzleutgeb/gradle2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, gradle2nix, examples }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
jdk = pkgs.jdk17;
z3 = pkgs.z3.override {
inherit jdk;
javaBindings = true;
};
graal = pkgs.graalvm17-ce;
javaToolchains = [ graal ];
gradle = (pkgs.gradle_7.override { inherit javaToolchains; });
solvers = with pkgs; [ alt-ergo cvc4 yices opensmt ];
atlasEnv = pkgs.buildEnv {
name = "atlas-env";
paths = [
gradle
z3
pkgs.dot2tex
pkgs.graphviz
gradle2nix.packages.${system}.gradle2nix
];
};
utils = with pkgs; [
calc
bash
bash-completion
coreutils
findutils
gitFull
gnugrep
less
moreutils
vim
];
in rec {
devShell.${system} = pkgs.mkShell {
buildInputs = [ atlasEnv ];
shellHook = ''
export LD_LIBRARY_PATH="${z3.lib}/lib"
export JAVA_HOME="${jdk}"
export GRAAL_HOME="${graal}"
export GRADLE_HOME="${gradle}"
$JAVA_HOME/bin/java -version
$GRAAL_HOME/bin/gu list
gradle -version
z3 --version
dot2tex --version
'';
};
defaultPackage.${system} = packages.${system}.atlas;
packages.${system} = rec {
atlas = (pkgs.callPackage ./gradle-env.nix { gradleBuildJdk = jdk; }) {
buildJdk = jdk;
gradlePackage = gradle;
envSpec = ./gradle-env.json;
src = ./.;
nativeBuildInputs = [ pkgs.bash pkgs.git pkgs.glibcLocales jdk z3 ];
ATLAS_HOME = "${examples}";
LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
LD_LIBRARY_PATH = "${z3.lib}/lib";
gradleFlags = [ "javaToolchains" "nativeCompile" ];
outputs = [ "out" ];
# JaCoCo broken with JDK 17.
#gradleFlags = [ "jacocoTestReport" "nativeImage" ];
#outputs = [ "out" "jacoco" ];
configurePhase = ''
locale
rm -rvf src/test/resources/examples
ln -svn ${examples} src/test/resources/examples
'';
installPhase = ''
mkdir -pv $out/var/atlas/resources $out/bin
cp -vR ${examples} $out/var/atlas/resources/examples
cp -vR $src/src/test/resources/tactics $out/var/atlas/resources/tactics
cp -v $src/atlas.{jsh,properties} $out/var/atlas
patchelf \
--add-needed libz3.so \
--add-needed libz3java.so \
--set-rpath ${pkgs.glibc}/lib:${z3.lib}/lib \
build/native/nativeCompile/atlas
cp -v build/native/nativeCompile/atlas $out/bin/atlas
# JaCoCo broken with JDK 17.
#cp -v build/reports/jacoco/test/jacocoTestReport.xml $jacoco
chmod ug+w $out/var/atlas/atlas.properties
echo "xyz.leutgeb.lorenz.atlas.module.Loader.defaultHome=$out/var/atlas/resources/examples" >> $out/var/atlas/atlas.properties
'';
meta.longDescription = ''
The atlas tool, along with some auxiliary files.
This derivation produces two outputs:
1. The standard output 'out' contains the binary as
`/bin/atlas` and auxiliary files under `/var/atlas`.
2. The output 'jacoco' which contains a test coverage
report in XML format.
JaCoCo broken with JDK 17.
'';
};
atlas-shell-docker = pkgs.dockerTools.buildLayeredImage {
name = "atlas-shell";
tag = "latest";
contents = utils ++ [
atlasEnv
packages.${system}.atlas
packages.${system}.atlas-cav
packages.${system}.atlas-src
];
config = { Entrypoint = [ "${pkgs.bash}/bin/bash" ]; };
};
atlas-docker = pkgs.dockerTools.buildLayeredImage {
name = "atlas";
tag = "latest";
contents = [ packages.${system}.atlas ];
config.Entrypoint = [ (packages.${system}.atlas + "/bin/atlas") ];
};
atlas-ova = nixosConfigurations.atlas.config.system.build.virtualBoxOVA;
atlas-src = pkgs.stdenv.mkDerivation {
name = "atlas-src";
src = ./.;
buildInputs = [ examples ];
buildPhase = ''
cp -Rv $src $out
chmod ug+rwx $out/src/test/resources
rm -rvf $out/src/test/resources/examples
ln -svn ${examples} $out/src/test/resources/examples
'';
installPhase = "true";
meta.longDescription = ''
Takes the contents of this repository and adds
examples to src/test/resources/examples as if
it would be initialized and updated as a Git
submodule.
'';
};
atlas-src-git = pkgs.stdenv.mkDerivation {
name = "atlas-src-git";
src = pkgs.fetchFromGitHub {
owner = "lorenzleutgeb";
repo = "atlas";
rev = "8c561d219ba4620f18bed35ead695bcfd2808acb";
hash = "sha256-aNXuchGIMh27nDIpuLWMlwStA8HKifIxIPNzm/Qx7KI=";
deepClone = true;
fetchSubmodules = true;
};
buildPhase = ''
cp -Rv $src $out
'';
installPhase = "true";
};
};
nixosConfigurations.atlas = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
#(nixpkgs + "/nixos/modules/installer/scan/not-detected.nix")
"${nixpkgs}/nixos/modules/virtualisation/virtualbox-image.nix"
"${nixpkgs}/nixos/modules/virtualisation/virtualbox-guest.nix"
home-manager.nixosModules.home-manager
({ pkgs, ... }: {
nix = {
package = pkgs.nixFlakes;
extraOptions = ''
allow-import-from-derivation = true
experimental-features = nix-command flakes
keep-outputs = true
'';
};
nixpkgs.config = { allowUnfree = true; };
virtualbox = {
vmName = "atlas";
vmFileName = "atlas.ova";
params = {
usb = "on";
usbehci = "off";
vram = 48;
};
};
environment = {
systemPackages = utils
++ [ self.packages.${system}.atlas pkgs.evince atlasEnv ];
variables = {
"ATLAS_HOME" = "/home/evaluator/atlas/src/resources/examples";
};
};
networking.hostName = "atlas";
users.users = {
evaluator = {
isNormalUser = true;
extraGroups = [ "wheel" ];
uid = 1000;
shell = pkgs.bash;
initialHashedPassword = "";
};
root.initialHashedPassword = "";
};
system.activationScripts.atlas.text = ''
cp -rv ${self.packages.${system}.atlas-src} /home/evaluator/atlas
rm -rf /home/evaluator/atlas/src/test/resources/examples
cp -rv ${examples} /home/evaluator/atlas/src/test/resources/examples
chown -R evaluator:$(id -g evaluator) /home/evaluator/atlas
chmod -R ug+w /home/evaluator/atlas
'';
home-manager.users.evaluator.home = {
file = let
referText = ''
See
/home/evaluator/atlas
Please first refer to the `README.md` of the tool itself
/home/evaluator/atlas/README.md
and afterwards to the "readme" of the artifact
/home/evaluator/atlas/ARTIFACT.md
Locations of some pre-installed software (all in `$PATH` as applicable):
atlas ${self.packages.${system}.atlas}
git ${pkgs.gitFull}
graal ${graal}
gradle ${gradle}
jdk ${jdk}
z3 ${z3}
'';
in {
"README.md".text = referText;
"Desktop/README.md".text = referText;
};
stateVersion = "22.05";
sessionVariables.ATLAS_HOME = "${examples}";
};
security.sudo.wheelNeedsPassword = false;
services = {
openssh.enable = true;
xserver = {
enable = true;
autorun = true;
desktopManager = {
xterm.enable = false;
xfce.enable = true;
};
displayManager = {
autoLogin = {
enable = true;
user = "evaluator";
};
defaultSession = "xfce";
};
};
};
})
];
};
};
}