From d768bf69a1ee47c8483273b9373763f88d434eb3 Mon Sep 17 00:00:00 2001 From: Ryan Hendrickson Date: Mon, 30 Oct 2023 19:45:15 -0400 Subject: [PATCH] maptool: extract application JARs from package ... instead of using the uber-JAR release. Packing the JARs together causes the JavaScript macro functionality not to work, as the scripting interface uses a ServiceLoader to find language providers via text file resources that share a common name. With one file per JAR, this works great. When multiple files with the same name are in one uber-JAR, all but one of them are shadowed, and the JavaScript language provider was getting lost. --- pkgs/games/maptool/default.nix | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/pkgs/games/maptool/default.nix b/pkgs/games/maptool/default.nix index eed8bac656be..d5fcbc47529b 100644 --- a/pkgs/games/maptool/default.nix +++ b/pkgs/games/maptool/default.nix @@ -13,15 +13,10 @@ let pname = "maptool"; version = "1.13.2"; - repoBase = "https://github.com/RPTools/${pname}"; + repoBase = "https://github.com/RPTools/maptool"; src = fetchurl { - url = "${repoBase}/releases/download/${version}/MapTool-${version}.jar"; - hash = "sha256-14ULI1OAk0V4DqiL5IF7DK6pw0NRfmU+omrFP72PblA="; - }; - - icon = fetchurl { - url = "https://raw.githubusercontent.com/RPTools/${pname}/${version}/package/linux/MapTool.png"; - hash = "sha256-xkVYjMprTanHu8r4b9PHORI8E1aJp+9KDSP5mqCE8ew="; + url = "${repoBase}/releases/download/${version}/maptool-${version}-x86_64.pkg.tar.zst"; + hash = "sha256-Ntmro+t4qpP5BXW20t97ki0wt2NKaK5yQarsxDEKbb0="; }; meta = with lib; { @@ -33,17 +28,20 @@ let ]; license = licenses.agpl3; maintainers = with maintainers; [ rhendric ]; + platforms = [ "x86_64-linux" ]; }; javafxModules = [ "base" "controls" "media" "swing" "web" "fxml" "graphics" ]; + appClasspath = "share/${pname}"; + classpath = lib.concatMap (mod: [ "${openjfx}/modules_src/javafx.${mod}/module-info.java" "${openjfx}/modules/javafx.${mod}" "${openjfx}/modules_libs/javafx.${mod}" ]) javafxModules ++ - [ src ]; + [ "$out/${appClasspath}/*" ]; jvmArgs = [ "-cp" (lib.concatStringsSep ":" classpath) @@ -76,6 +74,7 @@ stdenvNoCC.mkDerivation { inherit pname version src meta; dontUnpack = true; + dontConfigure = true; dontBuild = true; dontWrapGApps = true; @@ -99,15 +98,20 @@ stdenvNoCC.mkDerivation { installPhase = '' runHook preInstall - mkdir -p $out/bin - makeWrapper ${jre}/bin/java $out/bin/${binName} \ - "''${gappsWrapperArgs[@]}" \ - --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ ffmpeg ]} \ - --add-flags '${lib.concatStringsSep " " jvmArgs} net.rptools.maptool.client.LaunchInstructions' + dest=$out/${appClasspath} + install -dm755 "$dest" + bsdtar -xf "$src" -C "$dest" --strip-components 4 opt/maptool/lib/app/{'*.jar',readme} dest=$out/share/icons/hicolor/256x256/apps - mkdir -p "$dest" - ln -s ${icon} "$dest/${rdnsName}.png" + install -dm755 "$dest" + bsdtar -xOf "$src" opt/maptool/lib/MapTool.png > "$dest"/${rdnsName}.png + + dest=$out/bin + install -dm755 "$dest" + makeWrapper ${jre}/bin/java "$dest"/${binName} \ + "''${gappsWrapperArgs[@]}" \ + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ ffmpeg ]} \ + --add-flags "${lib.concatStringsSep " " jvmArgs} net.rptools.maptool.client.LaunchInstructions" runHook postInstall '';