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/papermc/default.nix

41 lines
1.4 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
stdenvNoCC,
openjdk_headless,
callPackage,
lib,
writeScript,
}: let
paperJar = callPackage ./jar.nix {};
versionInfo = builtins.fromJSON (builtins.readFile ./paper.json);
in
stdenvNoCC.mkDerivation {
preferLocalBuild = true;
pname = "paper";
version = "${versionInfo.version}.${toString versionInfo.build}";
dontUnpack = true;
dontConfigure = true;
buildPhase = ''
cat > minecraft-server << EOF
#!/bin/sh
exec ${openjdk_headless}/bin/java \$@ -jar $out/share/papermc/papermc.jar nogui
'';
installPhase = ''
mkdir -p $out/share/papermc
ln -s ${paperJar} $out/share/papermc/papermc.jar
install -Dm555 -t $out/bin minecraft-server
'';
meta = {
description = "High performance minecraft server";
# This is a fun one because while papermcs patches are released under the gpl, they apply patches to a proprietary binary which they then execute, so
license = lib.licenses.gpl3;
unfree = true;
};
passthru.updateScript = writeScript "update-paper" '' #! /usr/bin/env nix-shell
#! nix-shell -i bash -p curl jq
curl -L https://papermc.io/api/v2/projects/paper/versions/1.19.3/builds | jq '{"version":.version, "build":.builds[-1].build, "name":.builds[-1].downloads.application.name, "sha256":.builds[-1].downloads.application.sha256}' > minecraft/papermc/paper.json
'';
}