-
Notifications
You must be signed in to change notification settings - Fork 31
/
mkTextileLoader.nix
69 lines (59 loc) · 1.47 KB
/
mkTextileLoader.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
{ lib
, fetchurl
, stdenvNoCC
, unzip
, zip
, jre_headless
, loaderName
, loaderVersion
, gameVersion
, serverLaunch
, mainClass ? ""
, libraries
, extraBuildPhase ? ""
}:
let
inherit (builtins) head filter map match;
lib_lock = lib.importJSON ./libraries.json;
fetchedLibraries = lib.forEach libraries (l: fetchurl lib_lock.${l});
asmVersion = head (head (filter (v: v != null) (map (match "org\\.ow2\\.asm:asm:([\.0-9]+)") libraries)));
in
stdenvNoCC.mkDerivation {
pname = "${loaderName}-server-launch.jar";
version = "${loaderName}-${loaderVersion}-${gameVersion}";
nativeBuildInputs = [ unzip zip jre_headless ];
libraries = fetchedLibraries;
buildPhase = ''
for i in $libraries; do
unzip -o $i
done
cat > META-INF/MANIFEST.MF << EOF
Manifest-Version: 1.0
Main-Class: ${serverLaunch}
Name: org/objectweb/asm/
Implementation-Version: ${asmVersion}
EOF
${
if mainClass == "" then "" else ''
cat > ${loaderName}-server-launch.properties << EOF
launch.mainClass=${mainClass}
EOF
''
}
${extraBuildPhase}
'';
installPhase = ''
rm -f META-INF/*.{SF,RSA,DSA}
jar cmvf META-INF/MANIFEST.MF "server.jar" .
cp server.jar "$out"
'';
phases = [ "buildPhase" "installPhase" ];
passthru = {
inherit loaderName loaderVersion gameVersion;
propertyPrefix = {
"fabric" = "fabric";
"legacy-fabric" = "fabric";
"quilt" = "loader";
}.${loaderName};
};
}