summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/do/domination/package.nix
blob: c20b07542e650cc77374b2f5c6b09379ab16f01c (plain)
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
{
  lib,
  stdenv,
  fetchsvn,
  # jdk8 is needed for building, but the game runs on newer jres as well
  jdk8,
  jre,
  ant,
  stripJavaArchivesHook,
  makeWrapper,
  makeDesktopItem,
  copyDesktopItems,
  nixosTests,
}:

let
  desktopItem = makeDesktopItem {
    name = "domination";
    desktopName = "Domination";
    exec = "domination";
    icon = "domination";
  };
  editorDesktopItem = makeDesktopItem {
    name = "domination-map-editor";
    desktopName = "Domination Map Editor";
    exec = "domination-map-editor";
    icon = "domination";
  };

in
stdenv.mkDerivation {
  pname = "domination";
  version = "1.3.5";

  # The .zip releases do not contain the build.xml file
  src = fetchsvn {
    url = "https://svn.code.sf.net/p/domination/code/Domination";
    # There are no tags in the repository.
    # Look for "(svn rev X)" at
    # https://sourceforge.net/p/domination/code/HEAD/tree/Domination/ChangeLog.txt
    # Alternatively, look for revs like "changelog update",
    # "new version x.y.z info on website", or "website update for x.y.z".
    rev = "2778";
    hash = "sha256-OsCpSL/0QgaaUAzoyPPrAlJixRlqsLJu2D8FkEuo0Ak=";
  };

  nativeBuildInputs = [
    jdk8
    ant
    stripJavaArchivesHook
    makeWrapper
    copyDesktopItems
  ];

  buildPhase = ''
    runHook preBuild
    cd swingUI
    ant
    runHook postBuild
  '';

  desktopItems = [
    desktopItem
    editorDesktopItem
  ];

  installPhase = ''
    runHook preInstall
    # Remove unnecessary files and launchers (they'd need to be wrapped anyway)
    rm -r \
      build/game/src.zip \
      build/game/*.sh \
      build/game/*.cmd \
      build/game/*.exe \
      build/game/*.app

    mkdir -p $out/share/domination
    cp -r build/game/* $out/share/domination/

    # Reimplement the two launchers mentioned in Unix_shortcutSpec.xml with makeWrapper
    makeWrapper ${jre}/bin/java $out/bin/domination \
      --chdir "$out/share/domination" \
      --add-flags "-jar $out/share/domination/Domination.jar"
    makeWrapper ${jre}/bin/java $out/bin/domination-map-editor \
      --chdir "$out/share/domination" \
      --add-flags "-cp $out/share/domination/Domination.jar net.yura.domination.ui.swinggui.SwingGUIFrame"

    install -Dm644 build/game/resources/icon.png $out/share/icons/hicolor/16x16/apps/domination.png
    runHook postInstall
  '';

  preFixup = ''
    # remove extra metadata files for jar files which break stripJavaArchivesHook
    find $out/share/domination/lib -type f -name '._*.jar' -delete
  '';

  passthru.tests = {
    domination-starts = nixosTests.domination;
  };

  passthru.updateScript = ./update.tcl;

  meta = {
    homepage = "https://domination.sourceforge.net/";
    downloadPage = "https://domination.sourceforge.net/download.shtml";
    description = "Game that is a bit like the board game Risk or RisiKo";
    longDescription = ''
      Domination is a game that is a bit like the well known board game of Risk
      or RisiKo. It has many game options and includes many maps.
      It includes a map editor, a simple map format, multiplayer network play,
      single player, hotseat, 5 user interfaces and many more features.
    '';
    sourceProvenance = with lib.sourceTypes; [
      fromSource
      binaryBytecode # source bundles dependencies as jars
    ];
    license = lib.licenses.gpl3Plus;
    mainProgram = "domination";
    maintainers = with lib.maintainers; [ fgaz ];
    platforms = lib.platforms.all;
  };
}