This repository has been archived on 2024-10-13. You can view files and clone it, but cannot push or open issues or pull requests.
nix-packages/minecraft/paper.nix

29 lines
876 B
Nix

{pkgs, ...}: let
version-info = builtins.fromJSON (builtins.readFile ./paper.json);
pname = "paper";
mcVersion = version-info.version;
buildNum = toString version-info.build;
in rec {
paper-jar = pkgs.fetchurl {
url = "https://papermc.io/api/v2/projects/paper/versions/${mcVersion}/builds/${buildNum}/downloads/${version-info.name}";
inherit (version-info) sha256;
};
papermc = pkgs.stdenvNoCC.mkDerivation {
pname = "papermc";
version = "${mcVersion}-${buildNum}";
dontUnpack = true;
dontConfigure = true;
buildPhase = ''
cat > minecraft-server << EOF
#!${pkgs.bash}/bin/sh
exec ${pkgs.openjdk17_headless}/bin/java \$@ -jar $out/share/papermc/papermc.jar nogui
'';
installPhase = ''
ln -s ${paper-jar} $out/share/papermc/papermc.jar
install -Dm555 -t $out/bin minecraft-server
'';
};
}