about summary refs log tree commit diff
path: root/pkgs/games/maptool/default.nix
blob: 775879a957ad34a279c78f7f604343b827a11f93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{ lib
, copyDesktopItems
, fetchurl
, ffmpeg
, gitUpdater
, jre
, libarchive
, makeDesktopItem
, openjfx
, stdenvNoCC
, wrapGAppsHook3
}:
let
  pname = "maptool";
  version = "1.14.3";
  repoBase = "https://github.com/RPTools/maptool";
  src = fetchurl {
    url = "${repoBase}/releases/download/${version}/maptool-${version}-x86_64.pkg.tar.zst";
    hash = "sha256-KjP6zugQw9r1hvdxqOgTrt4hYMYg+lgjkgkj3tfb38s=";
  };

  meta = with lib; {
    description = "Virtual Tabletop for playing roleplaying games with remote players or face to face";
    mainProgram = "maptool";
    homepage = "https://www.rptools.net/toolbox/maptool/";
    sourceProvenance = with sourceTypes; [
      binaryBytecode
      binaryNativeCode
    ];
    license = licenses.agpl3Plus;
    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 ++
    [ "$out/${appClasspath}/*" ];

  jvmArgs = [
    "-cp" (lib.concatStringsSep ":" classpath)
    "-Xss8M"
    "-Dsun.java2d.d3d=false"
    "-Dfile.encoding=UTF-8"
    "-Dpolyglot.engine.WarnInterpreterOnly=false"
    "-XX:+ShowCodeDetailsInExceptionMessages"
    "--add-opens=java.desktop/java.awt=ALL-UNNAMED"
    "--add-opens=java.desktop/java.awt.geom=ALL-UNNAMED"
    "--add-opens=java.desktop/sun.awt.geom=ALL-UNNAMED"
    "--add-opens=java.base/java.util=ALL-UNNAMED"
    "--add-opens=javafx.web/javafx.scene.web=ALL-UNNAMED"
    "--add-opens=javafx.web/com.sun.webkit=ALL-UNNAMED"
    "--add-opens=javafx.web/com.sun.webkit.dom=ALL-UNNAMED"
    "--add-opens=java.desktop/javax.swing=ALL-UNNAMED"
    "--add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED"
    "--add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED"

    # disable telemetry (the empty DSN disables the Sentry library, setting the
    # environment to Development disables some logic inside MapTool)
    "-Dsentry.dsn"
    "-Dsentry.environment=Development"
  ];

  binName = pname;
  rdnsName = "net.rptools.maptool";
in
stdenvNoCC.mkDerivation {
  inherit pname version src meta;

  dontUnpack = true;
  dontConfigure = true;
  dontBuild = true;
  dontWrapGApps = true;

  nativeBuildInputs = [
    copyDesktopItems
    libarchive
    wrapGAppsHook3
  ];

  desktopItems = [
    (makeDesktopItem {
      name = rdnsName;
      desktopName = "MapTool";
      icon = rdnsName;
      exec = binName;
      comment = meta.description;
      categories = [ "Game" ];
    })
  ];

  installPhase = ''
    runHook preInstall

    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
    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
  '';

  passthru.updateScript = gitUpdater {
    url = "${repoBase}.git";
    ignoredVersions = "-";
  };
}