about summary refs log tree commit diff
path: root/pkgs/games/papermc/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/games/papermc/default.nix')
-rw-r--r--pkgs/games/papermc/default.nix63
1 files changed, 14 insertions, 49 deletions
diff --git a/pkgs/games/papermc/default.nix b/pkgs/games/papermc/default.nix
index aa16e51a7ac8..29d5c6b85203 100644
--- a/pkgs/games/papermc/default.nix
+++ b/pkgs/games/papermc/default.nix
@@ -1,50 +1,15 @@
-{
-  lib,
-  stdenvNoCC,
-  fetchurl,
-  jre,
-  makeBinaryWrapper,
-}:
-stdenvNoCC.mkDerivation (finalAttrs: {
-  pname = "papermc";
-  version = "1.20.4.435";
-
-  src =
-    let
-      mcVersion = lib.versions.pad 3 finalAttrs.version;
-      buildNum = builtins.elemAt (lib.splitVersion finalAttrs.version) 3;
-    in
-    fetchurl {
-      url = "https://papermc.io/api/v2/projects/paper/versions/${mcVersion}/builds/${buildNum}/downloads/paper-${mcVersion}-${buildNum}.jar";
-      hash = "sha256-NrIsYLoAAWORw/S26NDFjYBVwpNITJxuWGZow3696wM=";
-    };
-
-  installPhase = ''
-    runHook preInstall
-
-    install -D $src $out/share/papermc/papermc.jar
-
-    makeWrapper ${lib.getExe jre} "$out/bin/minecraft-server" \
-      --append-flags "-jar $out/share/papermc/papermc.jar nogui"
-
-    runHook postInstall
-  '';
-
-  nativeBuildInputs = [
-    makeBinaryWrapper
-  ];
-
-  dontUnpack = true;
-  preferLocalBuild = true;
-  allowSubstitutes = false;
-
-  meta = {
-    description = "High-performance Minecraft Server";
-    homepage = "https://papermc.io/";
-    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
-    license = lib.licenses.gpl3Only;
-    platforms = lib.platforms.unix;
-    maintainers = with lib.maintainers; [ aaronjanse neonfuz ];
-    mainProgram = "minecraft-server";
-  };
+{ callPackage, lib, ... }:
+let
+  versions = lib.importJSON ./versions.json;
+  latestVersion = lib.last (builtins.sort lib.versionOlder (builtins.attrNames versions));
+  escapeVersion = builtins.replaceStrings [ "." ] [ "_" ];
+  packages = lib.mapAttrs'
+    (version: value: {
+      name = "papermc-${escapeVersion version}";
+      value = callPackage ./derivation.nix { inherit (value) version hash; };
+    })
+    versions;
+in
+lib.recurseIntoAttrs (packages // {
+  papermc = builtins.getAttr "papermc-${escapeVersion latestVersion}" packages;
 })