-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
317 lines (294 loc) · 14 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
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ ];
};
lib = pkgs.lib;
text-rdt-sbt-launcher-source = lib.fileset.toSource {
root = ./text-rdt;
fileset = ./text-rdt/project/build.properties;
};
text-rdt-sbt-dependencies-source = lib.fileset.toSource {
root = ./text-rdt;
fileset = lib.fileset.unions
[
./text-rdt/build.sbt
./text-rdt/project/build.properties
./text-rdt/project/plugins.sbt
./text-rdt/.jvmopts
];
};
configureFonts = ''
export HOME=$(mktemp -d)
mkdir -p ~/.local/share/fonts
cp -r "${pkgs.dejavu_fonts}/share/fonts/truetype/." ~/.local/share/fonts
cp -r "${pkgs.freefont_ttf}/share/fonts/truetype/." ~/.local/share/fonts
cp -r "${pkgs.gyre-fonts}/share/fonts/truetype/." ~/.local/share/fonts
cp -r "${pkgs.liberation_ttf}/share/fonts/." ~/.local/share/fonts
cp -r "${pkgs.unifont}/share/fonts/." ~/.local/share/fonts
cp -r "${pkgs.noto-fonts.overrideAttrs rec {
version = "24.9.1";
src = pkgs.fetchFromGitHub {
owner = "notofonts";
repo = "notofonts.github.io";
rev = "noto-monthly-release-${version}";
hash = "sha256-QFRyHTJVz6MzayFvyTjDhc7eTAS4KXY3pqmx48VKNqY=";
};
installPhase = ''
# We check availability in order of variable -> otf -> ttf
# unhinted -- the hinted versions use autohint
# maintaining maximum coverage.
#
# We have a mix of otf and ttf fonts
local out_font=$out/share/fonts/noto
'' + (''
for folder in $(ls -d fonts/*/); do
if [[ -d "$folder"unhinted/otf ]]; then
install -m444 -Dt $out_font "$folder"unhinted/otf/*.otf
elif [[ -d "$folder"unhinted/variable ]]; then
install -m444 -Dt $out_font "$folder"unhinted/variable/*
elif [[ -d "$folder"unhinted/variable-ttf ]]; then
install -m444 -Dt $out_font "$folder"unhinted/variable-ttf/*.ttf
else
install -m444 -Dt $out_font "$folder"unhinted/ttf/*.ttf
fi
done
'') + ''
${pkgs.rename}/bin/rename 's/\[.*\]//' $out/share/fonts/noto/*
'';
}}/share/fonts/noto/." ~/.local/share/fonts
${pkgs.tree}/bin/tree ~/.local/share/fonts | grep NotoSansMono
ls -lh ~/.local/share/fonts/ | grep NotoSansMono # cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
#${pkgs.fontconfig}/bin/fc-list
'';
in
{
devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.bashInteractive pkgs.sbt pkgs.openjdk21 pkgs.nodejs pkgs.vscodium pkgs.openssl ];
nativeBuildInputs = [ pkgs.pkg-config ];
JAVA_HOME = pkgs.openjdk21;
};
# TOOD IMplement sbt honoring the cores parameter
packages.text-rdt-npm-dependencies = pkgs.buildNpmPackage rec {
name = "text-rdt-npm-dependencies";
srcs = lib.fileset.toSource {
root = ./text-rdt;
fileset = lib.fileset.union
./text-rdt/package.json
./text-rdt/package-lock.json;
};
dontNpmBuild = true;
installPhase = ''
cp -r node_modules $out
'';
npmDepsHash = "sha256-+3gXE+zHx8EbcZiEdUvD9uUz6bdgiKy3ptHnWXRkdcc=";
};
packages.empty-dependencies = pkgs.buildNpmPackage rec {
name = "empty-npm-package";
srcs = ./.nix/fake-project;
dontNpmBuild = true;
installPhase = ''
cp -r node_modules $out
'';
npmDepsHash = "sha256-5uTYs6Qm5zRWE51MCtR5PQQXeoXPiBxeamL5XxkLZ1w=";
};
packages.text-rdt-sbt-launcher-fod = pkgs.stdenv.mkDerivation {
name = "text-rdt-sbt-launcher-fod-${text-rdt-sbt-launcher-source}";
srcs = text-rdt-sbt-launcher-source;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-JkZIyl4h+ZoTGoAu4KiM2jB9We6mHZaMYk+0qJEskzo=";
configurePhase = ''
export SBT_LAUNCHER=$(mktemp -d)
export SBT_OPTS="-Dsbt.boot.lock=false -Dsbt.boot.directory=$SBT_LAUNCHER"
'';
buildPhase = ''
${pkgs.sbt}/bin/sbt shutdown
'';
installPhase = ''
cp -r $SBT_LAUNCHER $out/
'';
};
packages.text-rdt-sbt-dependencies-fod =
pkgs.stdenv.mkDerivation {
name = "text-rdt-sbt-dependencies-fod-${text-rdt-sbt-dependencies-source}";
srcs = text-rdt-sbt-dependencies-source;
nativeBuildInputs = [ pkgs.cacert ];
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-aP2BgRzdijwn1CokDoWwvzmIhBS0ckO58f7VlFvjJgU=";
configurePhase = ''
export HOME=$(mktemp -d)
export IVY=$(mktemp -d)
export COURSIER_CACHE=$(mktemp -d)
export SBT_OPTS="$SBT_OPTS -Dsbt.boot.lock=false -Dsbt.boot.directory=${self.packages.${system}.text-rdt-sbt-launcher-fod}"
'';
buildPhase = ''
cp -r ${self.packages.${system}.empty-dependencies} node_modules
cp -r ${./.nix/fake-project}/* .
mkdir -p js/src/main/scala/text_rdt
echo '
package text_rdt
object JSMain {
@main
def main(): Unit = {
}
}' > js/src/main/scala/text_rdt/JSMain.scala
${pkgs.sbt}/bin/sbt "update; fastLinkJS"
'';
installPhase = ''
${pkgs.coreutils}/bin/cp -r $COURSIER_CACHE $out
'';
};
packages.text-rdt-sbt-scalablytyped = pkgs.stdenv.mkDerivation {
name = "text-rdt-sbt-scalablytyped";
srcs = lib.fileset.toSource {
root = ./text-rdt;
fileset = lib.fileset.unions
[
./text-rdt/build.sbt
./text-rdt/project/build.properties
./text-rdt/project/plugins.sbt
./text-rdt/.jvmopts
./text-rdt/package.json
./text-rdt/package-lock.json
];
};
configurePhase = ''
export IVY=$(mktemp -d)
export SBT_OPTS="-Dsbt.ivy.home=$IVY -Dsbt.boot.lock=false -Dsbt.boot.directory=${self.packages.${system}.text-rdt-sbt-launcher-fod}"
export COURSIER_CACHE=${self.packages.${system}.text-rdt-sbt-dependencies-fod}
ln -s ${self.packages.${system}.text-rdt-npm-dependencies} node_modules
'';
buildPhase = ''
${pkgs.sbt}/bin/sbt update
'';
installPhase = ''
mkdir $out
${pkgs.coreutils}/bin/cp -r $IVY/ $out/ivy
${pkgs.coreutils}/bin/cp -r /build/.cache/scalablytyped/ $out/scalablytyped
'';
};
packages.async-profiler-converter = pkgs.fetchurl {
url = "https://github.com/async-profiler/async-profiler/releases/download/v3.0/converter.jar";
hash = "sha256-5kZTMaZgnfGFLA6Dufw3/eUTmlfBhm/HgRpeXEJ7Y2s=";
};
packages.figures = pkgs.stdenv.mkDerivation {
name = "text-rdt-sbt";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions
[
./text-rdt
./latex/figures/gnuplot.txt
];
};
buildPhase = ''
${configureFonts}
ls -d text-rdt/jvm/figure-benchmark-results/*/ | xargs -I {} bash -c "cd {} && ${pkgs.openjdk}/bin/java -jar ${self.packages.${system}.async-profiler-converter} jfr2flame jfr-cpu.jfr cpu.html"
ls -d text-rdt/jvm/figure-benchmark-results/*/ | xargs -I {} bash -c "cd {} && ${pkgs.openjdk}/bin/java -jar ${self.packages.${system}.async-profiler-converter} jfr2flame --alloc --simple jfr-cpu.jfr alloc.html"
export XDG_CACHE_HOME="$(mktemp -d)"
${pkgs.gnuplot}/bin/gnuplot latex/figures/gnuplot.txt # todo split into separate derivation # liberation sans
'';
installPhase = ''
cp -r text-rdt/jvm/figure-benchmark-results $out
'';
};
packages.latex = pkgs.stdenv.mkDerivation {
name = "Bachelor_Thesis_Moritz_Hedtke_Optimizing_Collaborative_Plain_Text_Editing_Algorithms.pdf";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions
[
./latex
];
};
# https://www.google.com/search?q=site%3Amiktex.org+%22caption.sty%22
# texliveInfraOnly
nativeBuildInputs = [ pkgs.git (pkgs.texliveBasic.withPackages (ps: with ps; [ latexmk luatex pdfmanagement-testphase tagpdf etoolbox l3experimental tuda-ci urcls koma-script xcolor anyfontsize fontspec xcharter roboto xkeyval adjustbox pgf babel-german microtype unicode-math lualatex-math glossaries-extra glossaries fancyvrb minted upquote caption csquotes biblatex cleveref biber ])) pkgs.python3Packages.pygments ];
configurePhase = ''
mkdir -p text-rdt/target
cp -r ${self.packages.${system}.text-rdt-sbt-tests-thesis} text-rdt/target/pdfs
mkdir -p text-rdt/jvm
cp -r ${self.packages.${system}.figures} text-rdt/jvm/figure-benchmark-results
export HOME=$(mktemp -d)
'';
buildPhase = ''
cd latex
make
cd ..
'';
installPhase = ''
cp latex/thesis.pdf $out
'';
};
packages.latex-info = (pkgs.runCommand "my-example" { } ''
${pkgs.poppler_utils}/bin/pdfinfo ${self.packages.${system}.latex}
echo -------------------------------------------------------------
${pkgs.exiftool}/bin/exiftool ${self.packages.${system}.latex}
echo -------------------------------------------------------------
${pkgs.verapdf}/bin/verapdf --flavour 3a --format text ${self.packages.${system}.latex}
echo -------------------------------------------------------------
${pkgs.poppler_utils}/bin/pdffonts ${self.packages.${system}.latex} # TODO check no "Type 3"
cp ${self.packages.${system}.latex} $out
'');
packages.text-rdt-sbt-tests-all = self.packages.${system}.text-rdt-sbt-tests-of "test";
packages.text-rdt-sbt-tests-thesis = self.packages.${system}.text-rdt-sbt-tests-of "testOnly text_rdt.ThesisTestSuite";
packages.text-rdt-sbt-tests-of = target: pkgs.stdenv.mkDerivation {
name = "text-rdt-sbt-tests";
src = ./text-rdt;
nativeBuildInputs = [ pkgs.sbt ];
configurePhase = ''
${configureFonts}
mkdir /build/.cache
ln -s ${self.packages.${system}.text-rdt-sbt-scalablytyped}/scalablytyped /build/.cache/
export SBT_OPTS="-Dsbt.ivy.home=${self.packages.${system}.text-rdt-sbt-scalablytyped}/ivy -Dsbt.boot.lock=false -Dsbt.boot.directory=${self.packages.${system}.text-rdt-sbt-launcher-fod}"
export COURSIER_CACHE=${self.packages.${system}.text-rdt-sbt-dependencies-fod}
cp -r ${self.packages.${system}.text-rdt-npm-dependencies} node_modules
cp -r ${self.packages.${system}.figures}/. jvm/figure-benchmark-results/
'';
PLAYWRIGHT_NODEJS_PATH = "${pkgs.nodejs}/bin/node";
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true;
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = true;
PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}";
buildPhase = ''
${pkgs.nodejs}/bin/npm run build -- --base=./ # TODO split this up
${pkgs.nodejs}/bin/npm run preview &
${pkgs.sbt}/bin/sbt "textrdtJVM/${target}"
'';
installPhase = ''
cp -r target/pdfs/. $out
${pkgs.poppler_utils}/bin/pdffonts $out/empty.pdf
'';
};
# GOAL 1: Build web application
packages.text-rdt-frontend = pkgs.stdenv.mkDerivation {
name = "text-rdt-frontend";
src = ./text-rdt;
nativeBuildInputs = [ pkgs.sbt ];
configurePhase = ''
mkdir /build/.cache
ln -s ${self.packages.${system}.text-rdt-sbt-scalablytyped}/scalablytyped /build/.cache/
export SBT_OPTS="-Dsbt.ivy.home=${self.packages.${system}.text-rdt-sbt-scalablytyped}/ivy -Dsbt.boot.lock=false -Dsbt.boot.directory=${self.packages.${system}.text-rdt-sbt-launcher-fod}"
export COURSIER_CACHE=${self.packages.${system}.text-rdt-sbt-dependencies-fod}
cp -r ${self.packages.${system}.text-rdt-npm-dependencies} node_modules
'';
buildPhase = ''
${pkgs.nodejs}/bin/npm run build -- --base=./
'';
installPhase = ''
cp -r dist $out
'';
};
}
);
}