1{
2 lib,
3 stdenv,
4 fetchsvn,
5 # jdk8 is needed for building, but the game runs on newer jres as well
6 jdk8,
7 jre,
8 ant,
9 stripJavaArchivesHook,
10 makeWrapper,
11 makeDesktopItem,
12 copyDesktopItems,
13 nixosTests,
14}:
15
16let
17 desktopItem = makeDesktopItem {
18 name = "domination";
19 desktopName = "Domination";
20 exec = "domination";
21 icon = "domination";
22 };
23 editorDesktopItem = makeDesktopItem {
24 name = "domination-map-editor";
25 desktopName = "Domination Map Editor";
26 exec = "domination-map-editor";
27 icon = "domination";
28 };
29
30in
31stdenv.mkDerivation {
32 pname = "domination";
33 version = "1.3.4";
34
35 # The .zip releases do not contain the build.xml file
36 src = fetchsvn {
37 url = "https://svn.code.sf.net/p/domination/code/Domination";
38 # There are no tags in the repository.
39 # Look for "(svn rev X)" at
40 # https://sourceforge.net/p/domination/code/HEAD/tree/Domination/ChangeLog.txt
41 # Alternatively, look for revs like "changelog update",
42 # "new version x.y.z info on website", or "website update for x.y.z".
43 rev = "2664";
44 hash = "sha256-bkaHpqJSc3UvwNT7LwuPUT8xN0g6QypfLSHlLmm8nX8=";
45 };
46
47 nativeBuildInputs = [
48 jdk8
49 ant
50 stripJavaArchivesHook
51 makeWrapper
52 copyDesktopItems
53 ];
54
55 buildPhase = ''
56 runHook preBuild
57 cd swingUI
58 ant
59 runHook postBuild
60 '';
61
62 desktopItems = [
63 desktopItem
64 editorDesktopItem
65 ];
66
67 installPhase = ''
68 runHook preInstall
69 # Remove unnecessary files and launchers (they'd need to be wrapped anyway)
70 rm -r \
71 build/game/src.zip \
72 build/game/*.sh \
73 build/game/*.cmd \
74 build/game/*.exe \
75 build/game/*.app
76
77 mkdir -p $out/share/domination
78 cp -r build/game/* $out/share/domination/
79
80 # Reimplement the two launchers mentioned in Unix_shortcutSpec.xml with makeWrapper
81 makeWrapper ${jre}/bin/java $out/bin/domination \
82 --chdir "$out/share/domination" \
83 --add-flags "-jar $out/share/domination/Domination.jar"
84 makeWrapper ${jre}/bin/java $out/bin/domination-map-editor \
85 --chdir "$out/share/domination" \
86 --add-flags "-cp $out/share/domination/Domination.jar net.yura.domination.ui.swinggui.SwingGUIFrame"
87
88 install -Dm644 build/game/resources/icon.png $out/share/pixmaps/domination.png
89 runHook postInstall
90 '';
91
92 preFixup = ''
93 # remove extra metadata files for jar files which break stripJavaArchivesHook
94 find $out/share/domination/lib -type f -name '._*.jar' -delete
95 '';
96
97 passthru.tests = {
98 domination-starts = nixosTests.domination;
99 };
100
101 passthru.updateScript = ./update.tcl;
102
103 meta = with lib; {
104 homepage = "https://domination.sourceforge.net/";
105 downloadPage = "https://domination.sourceforge.net/download.shtml";
106 description = "Game that is a bit like the board game Risk or RisiKo";
107 longDescription = ''
108 Domination is a game that is a bit like the well known board game of Risk
109 or RisiKo. It has many game options and includes many maps.
110 It includes a map editor, a simple map format, multiplayer network play,
111 single player, hotseat, 5 user interfaces and many more features.
112 '';
113 sourceProvenance = with sourceTypes; [
114 fromSource
115 binaryBytecode # source bundles dependencies as jars
116 ];
117 license = licenses.gpl3Plus;
118 mainProgram = "domination";
119 maintainers = with maintainers; [ fgaz ];
120 platforms = platforms.all;
121 };
122}