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