nix-fabric/fabric-server.nix

57 lines
1 KiB
Nix
Raw Permalink Normal View History

2024-10-15 23:14:48 +00:00
{ lib
, callPackage
, fetchurl
, writeShellApplication
, udev
, jdk_headless
, minecraftVersion
, fabricLoaderVersion
, serverJarUrl
, serverJarSha1
, mainClass
, libraries
, extraJvmArgs ? []
2024-10-18 16:18:45 +00:00
, fabricMods ? []
2024-10-15 23:14:48 +00:00
}:
let
fetchLib = library: fetchurl {
url = library.url;
hash = library.sha256;
};
officialServerJar = fetchurl {
url = serverJarUrl;
sha1 = serverJarSha1;
meta = with lib; {
sourceProvenance = with sourceTypes; [ binaryBytecode ];
license = licenses.unfreeRedistributable;
};
};
classPath = lib.concatStringsSep ":" (map fetchLib libraries);
2024-10-18 16:18:45 +00:00
modList = lib.concatStringsSep ":" fabricMods;
2024-10-15 23:14:48 +00:00
in
writeShellApplication {
name = "fabric-server";
runtimeInputs = [ jdk_headless ];
text = ''
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lib.makeLibraryPath [udev]}
export LD_LIBRARY_PATH
exec java -Dfabric.gameJarPath=${officialServerJar} \
-Dfabric.addMods=${modList} \
${lib.escapeShellArgs extraJvmArgs} \
-cp ${classPath} \
${mainClass} \
nogui
'';
}