minecraft-server: fix using latest jre for all minecraft server versions

This commit is contained in:
Joel 2021-12-15 15:29:56 +10:00 committed by tomberek
parent 63c488bf3b
commit e0843a80e2
4 changed files with 51 additions and 20 deletions

View File

@ -1,14 +1,20 @@
{ callPackage, lib }: { callPackage, lib, javaPackages }:
# if you add more versions make sure to add to all-packages.nix # if you add more versions make sure to add to all-packages.nix
let let
versions = lib.importJSON ./versions.json; versions = lib.importJSON ./versions.json;
latestVersion = lib.last (builtins.sort lib.versionOlder (builtins.attrNames versions)); latestVersion = lib.last (builtins.sort lib.versionOlder (builtins.attrNames versions));
escapeVersion = builtins.replaceStrings [ "." ] [ "_" ]; escapeVersion = builtins.replaceStrings [ "." ] [ "_" ];
getJavaVersion = v: (builtins.getAttr "openjdk${toString v}" javaPackages.compiler).headless;
packages = lib.mapAttrs' packages = lib.mapAttrs'
(version: value: { (version: value: {
name = "minecraft-server_${escapeVersion version}"; name = "minecraft-server_${escapeVersion version}";
value = callPackage ./derivation.nix { inherit (value) version url sha1; }; value = callPackage ./derivation.nix {
inherit (value) version url sha1;
jre_headless = getJavaVersion (if value.javaVersion == null then 8 else value.javaVersion); # versions <= 1.6 will default to 8
};
}) })
versions; versions;
in in

View File

@ -55,6 +55,13 @@ class Version(DataClassJsonMixin):
for download_name, download_info in self.get_manifest()["downloads"].items() for download_name, download_info in self.get_manifest()["downloads"].items()
} }
def get_java_version(self) -> Any:
"""
Return the java version specified in a version's manifest, if it is
present. Versions <= 1.6 do not specify this.
"""
return self.get_manifest().get("javaVersion", {}).get("majorVersion", None)
def get_server(self) -> Optional[Download]: def get_server(self) -> Optional[Download]:
""" """
If the version has a server download available, return the Download If the version has a server download available, return the Download
@ -138,6 +145,7 @@ def generate() -> Dict[str, Dict[str, str]]:
for version, server in servers.items(): for version, server in servers.items():
server["version"] = latest_major_releases[version].id server["version"] = latest_major_releases[version].id
server["javaVersion"] = latest_major_releases[version].get_java_version()
return servers return servers

View File

@ -2,86 +2,103 @@
"1.18": { "1.18": {
"url": "https://launcher.mojang.com/v1/objects/125e5adf40c659fd3bce3e66e67a16bb49ecc1b9/server.jar", "url": "https://launcher.mojang.com/v1/objects/125e5adf40c659fd3bce3e66e67a16bb49ecc1b9/server.jar",
"sha1": "125e5adf40c659fd3bce3e66e67a16bb49ecc1b9", "sha1": "125e5adf40c659fd3bce3e66e67a16bb49ecc1b9",
"version": "1.18.1" "version": "1.18.1",
"javaVersion": 17
}, },
"1.17": { "1.17": {
"url": "https://launcher.mojang.com/v1/objects/a16d67e5807f57fc4e550299cf20226194497dc2/server.jar", "url": "https://launcher.mojang.com/v1/objects/a16d67e5807f57fc4e550299cf20226194497dc2/server.jar",
"sha1": "a16d67e5807f57fc4e550299cf20226194497dc2", "sha1": "a16d67e5807f57fc4e550299cf20226194497dc2",
"version": "1.17.1" "version": "1.17.1",
"javaVersion": 16
}, },
"1.16": { "1.16": {
"url": "https://launcher.mojang.com/v1/objects/1b557e7b033b583cd9f66746b7a9ab1ec1673ced/server.jar", "url": "https://launcher.mojang.com/v1/objects/1b557e7b033b583cd9f66746b7a9ab1ec1673ced/server.jar",
"sha1": "1b557e7b033b583cd9f66746b7a9ab1ec1673ced", "sha1": "1b557e7b033b583cd9f66746b7a9ab1ec1673ced",
"version": "1.16.5" "version": "1.16.5",
"javaVersion": 8
}, },
"1.15": { "1.15": {
"url": "https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar", "url": "https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar",
"sha1": "bb2b6b1aefcd70dfd1892149ac3a215f6c636b07", "sha1": "bb2b6b1aefcd70dfd1892149ac3a215f6c636b07",
"version": "1.15.2" "version": "1.15.2",
"javaVersion": 8
}, },
"1.14": { "1.14": {
"url": "https://launcher.mojang.com/v1/objects/3dc3d84a581f14691199cf6831b71ed1296a9fdf/server.jar", "url": "https://launcher.mojang.com/v1/objects/3dc3d84a581f14691199cf6831b71ed1296a9fdf/server.jar",
"sha1": "3dc3d84a581f14691199cf6831b71ed1296a9fdf", "sha1": "3dc3d84a581f14691199cf6831b71ed1296a9fdf",
"version": "1.14.4" "version": "1.14.4",
"javaVersion": 8
}, },
"1.13": { "1.13": {
"url": "https://launcher.mojang.com/v1/objects/3737db93722a9e39eeada7c27e7aca28b144ffa7/server.jar", "url": "https://launcher.mojang.com/v1/objects/3737db93722a9e39eeada7c27e7aca28b144ffa7/server.jar",
"sha1": "3737db93722a9e39eeada7c27e7aca28b144ffa7", "sha1": "3737db93722a9e39eeada7c27e7aca28b144ffa7",
"version": "1.13.2" "version": "1.13.2",
"javaVersion": 8
}, },
"1.12": { "1.12": {
"url": "https://launcher.mojang.com/v1/objects/886945bfb2b978778c3a0288fd7fab09d315b25f/server.jar", "url": "https://launcher.mojang.com/v1/objects/886945bfb2b978778c3a0288fd7fab09d315b25f/server.jar",
"sha1": "886945bfb2b978778c3a0288fd7fab09d315b25f", "sha1": "886945bfb2b978778c3a0288fd7fab09d315b25f",
"version": "1.12.2" "version": "1.12.2",
"javaVersion": 8
}, },
"1.11": { "1.11": {
"url": "https://launcher.mojang.com/v1/objects/f00c294a1576e03fddcac777c3cf4c7d404c4ba4/server.jar", "url": "https://launcher.mojang.com/v1/objects/f00c294a1576e03fddcac777c3cf4c7d404c4ba4/server.jar",
"sha1": "f00c294a1576e03fddcac777c3cf4c7d404c4ba4", "sha1": "f00c294a1576e03fddcac777c3cf4c7d404c4ba4",
"version": "1.11.2" "version": "1.11.2",
"javaVersion": 8
}, },
"1.10": { "1.10": {
"url": "https://launcher.mojang.com/v1/objects/3d501b23df53c548254f5e3f66492d178a48db63/server.jar", "url": "https://launcher.mojang.com/v1/objects/3d501b23df53c548254f5e3f66492d178a48db63/server.jar",
"sha1": "3d501b23df53c548254f5e3f66492d178a48db63", "sha1": "3d501b23df53c548254f5e3f66492d178a48db63",
"version": "1.10.2" "version": "1.10.2",
"javaVersion": 8
}, },
"1.9": { "1.9": {
"url": "https://launcher.mojang.com/v1/objects/edbb7b1758af33d365bf835eb9d13de005b1e274/server.jar", "url": "https://launcher.mojang.com/v1/objects/edbb7b1758af33d365bf835eb9d13de005b1e274/server.jar",
"sha1": "edbb7b1758af33d365bf835eb9d13de005b1e274", "sha1": "edbb7b1758af33d365bf835eb9d13de005b1e274",
"version": "1.9.4" "version": "1.9.4",
"javaVersion": 8
}, },
"1.8": { "1.8": {
"url": "https://launcher.mojang.com/v1/objects/b58b2ceb36e01bcd8dbf49c8fb66c55a9f0676cd/server.jar", "url": "https://launcher.mojang.com/v1/objects/b58b2ceb36e01bcd8dbf49c8fb66c55a9f0676cd/server.jar",
"sha1": "b58b2ceb36e01bcd8dbf49c8fb66c55a9f0676cd", "sha1": "b58b2ceb36e01bcd8dbf49c8fb66c55a9f0676cd",
"version": "1.8.9" "version": "1.8.9",
"javaVersion": 8
}, },
"1.7": { "1.7": {
"url": "https://launcher.mojang.com/v1/objects/4cec86a928ec171fdc0c6b40de2de102f21601b5/server.jar", "url": "https://launcher.mojang.com/v1/objects/4cec86a928ec171fdc0c6b40de2de102f21601b5/server.jar",
"sha1": "4cec86a928ec171fdc0c6b40de2de102f21601b5", "sha1": "4cec86a928ec171fdc0c6b40de2de102f21601b5",
"version": "1.7.9" "version": "1.7.9",
"javaVersion": 8
}, },
"1.6": { "1.6": {
"url": "https://launcher.mojang.com/v1/objects/050f93c1f3fe9e2052398f7bd6aca10c63d64a87/server.jar", "url": "https://launcher.mojang.com/v1/objects/050f93c1f3fe9e2052398f7bd6aca10c63d64a87/server.jar",
"sha1": "050f93c1f3fe9e2052398f7bd6aca10c63d64a87", "sha1": "050f93c1f3fe9e2052398f7bd6aca10c63d64a87",
"version": "1.6.4" "version": "1.6.4",
"javaVersion": null
}, },
"1.5": { "1.5": {
"url": "https://launcher.mojang.com/v1/objects/f9ae3f651319151ce99a0bfad6b34fa16eb6775f/server.jar", "url": "https://launcher.mojang.com/v1/objects/f9ae3f651319151ce99a0bfad6b34fa16eb6775f/server.jar",
"sha1": "f9ae3f651319151ce99a0bfad6b34fa16eb6775f", "sha1": "f9ae3f651319151ce99a0bfad6b34fa16eb6775f",
"version": "1.5.2" "version": "1.5.2",
"javaVersion": null
}, },
"1.4": { "1.4": {
"url": "https://launcher.mojang.com/v1/objects/2f0ec8efddd2f2c674c77be9ddb370b727dec676/server.jar", "url": "https://launcher.mojang.com/v1/objects/2f0ec8efddd2f2c674c77be9ddb370b727dec676/server.jar",
"sha1": "2f0ec8efddd2f2c674c77be9ddb370b727dec676", "sha1": "2f0ec8efddd2f2c674c77be9ddb370b727dec676",
"version": "1.4.7" "version": "1.4.7",
"javaVersion": null
}, },
"1.3": { "1.3": {
"url": "https://launcher.mojang.com/v1/objects/3de2ae6c488135596e073a9589842800c9f53bfe/server.jar", "url": "https://launcher.mojang.com/v1/objects/3de2ae6c488135596e073a9589842800c9f53bfe/server.jar",
"sha1": "3de2ae6c488135596e073a9589842800c9f53bfe", "sha1": "3de2ae6c488135596e073a9589842800c9f53bfe",
"version": "1.3.2" "version": "1.3.2",
"javaVersion": null
}, },
"1.2": { "1.2": {
"url": "https://launcher.mojang.com/v1/objects/d8321edc9470e56b8ad5c67bbd16beba25843336/server.jar", "url": "https://launcher.mojang.com/v1/objects/d8321edc9470e56b8ad5c67bbd16beba25843336/server.jar",
"sha1": "d8321edc9470e56b8ad5c67bbd16beba25843336", "sha1": "d8321edc9470e56b8ad5c67bbd16beba25843336",
"version": "1.2.5" "version": "1.2.5",
"javaVersion": null
} }
} }

View File

@ -30810,7 +30810,7 @@ with pkgs;
minecraft = callPackage ../games/minecraft { }; minecraft = callPackage ../games/minecraft { };
inherit (import ../games/minecraft-server { inherit callPackage lib; }) inherit (import ../games/minecraft-server { inherit callPackage lib javaPackages; })
minecraft-server_1_2 minecraft-server_1_2
minecraft-server_1_3 minecraft-server_1_3
minecraft-server_1_4 minecraft-server_1_4