git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #53300 from msteen/openra

openra with extra mods

commit6bc8a6621296d073974c4537933b53aa029edde5 authorDmitry Kalinkin <dmitry.kalinkin@gmail.com> dateThu 10 Jan 2019, 13:56 (8 years ago) parent9fac2251ae7384
11 files changed+795−69
pkgs/games/openra/common.nix+87 pkgs/games/openra/default.nix+61−68 pkgs/games/openra/engine.nix+60 pkgs/games/openra/engines.nix+41 pkgs/games/openra/mkdirp.sh+4 pkgs/games/openra/mod-launch-game.sh+25 pkgs/games/openra/mod.nix+104 pkgs/games/openra/mods.nix+339 pkgs/games/openra/openra-mod.desktop+11 pkgs/games/openra/packages.nix+60 pkgs/top-level/all-packages.nix+3−1
pkgs/games/openra/common.nixnew file+87
@@ -0,0 +1,87 @@
1+/* The reusable code, and package attributes, between OpenRA engine packages (engine.nix)
2+ and out-of-tree mod packages (mod.nix).
3+*/
4+{ stdenv, makeSetupHook, curl, unzip, dos2unix, pkgconfig, makeWrapper
5+, lua, mono, dotnetPackages, python
6+, libGL, openal, SDL2
7+, zenity
8+}:
9+
10+with stdenv.lib;
11+
12+let
13+ path = makeBinPath ([ mono python ] ++ optional (zenity != null) zenity);
14+ rpath = makeLibraryPath [ lua openal SDL2 ];
15+ mkdirp = makeSetupHook { } ./mkdirp.sh;
16+
17+in {
18+ patchEngine = dir: version: ''
19+ sed -i \
20+ -e 's/^VERSION.*/VERSION = ${version}/g' \
21+ -e '/fetch-geoip-db/d' \
22+ -e '/GeoLite2-Country.mmdb.gz/d' \
23+ ${dir}/Makefile
24+
25+ sed -i 's|locations=.*|locations=${lua}/lib|' ${dir}/thirdparty/configure-native-deps.sh
26+ '';
27+
28+ wrapLaunchGame = openraSuffix: ''
29+ # Setting TERM=xterm fixes an issue with terminfo in mono: System.Exception: Magic number is wrong: 542
30+ # https://github.com/mono/mono/issues/6752#issuecomment-365212655
31+ wrapProgram $out/lib/openra${openraSuffix}/launch-game.sh \
32+ --prefix PATH : "${path}" \
33+ --prefix LD_LIBRARY_PATH : "${rpath}" \
34+ --set TERM xterm
35+
36+ makeWrapper $out/lib/openra${openraSuffix}/launch-game.sh $(mkdirp $out/bin)/openra${openraSuffix} \
37+ --run "cd $out/lib/openra${openraSuffix}"
38+ '';
39+
40+ packageAttrs = {
41+ buildInputs = with dotnetPackages; [
42+ FuzzyLogicLibrary
43+ MaxMindDb
44+ MaxMindGeoIP2
45+ MonoNat
46+ NewtonsoftJson
47+ NUnit3
48+ NUnitConsole
49+ OpenNAT
50+ RestSharp
51+ SharpFont
52+ SharpZipLib
53+ SmartIrc4net
54+ StyleCopMSBuild
55+ StyleCopPlusMSBuild
56+ ] ++ [
57+ lua
58+ libGL
59+ openal
60+ SDL2
61+ ];
62+
63+ # TODO: Test if this is correct.
64+ nativeBuildInputs = [
65+ curl
66+ unzip
67+ dos2unix
68+ pkgconfig
69+ makeWrapper
70+ mkdirp
71+ mono
72+ python
73+ ];
74+
75+ makeFlags = "prefix=$(out)";
76+
77+ doCheck = true;
78+
79+ dontStrip = true;
80+
81+ meta = {
82+ maintainers = with maintainers; [ msteen rardiol ];
83+ license = licenses.gpl3;
84+ platforms = platforms.linux;
85+ };
86+ };
87+}
pkgs/games/openra/default.nix+61−68
@@ -1,79 +1,72 @@
1−{ stdenv, fetchFromGitHub, mono, makeWrapper, lua
2−, SDL2, freetype, openal, systemd, pkgconfig,
3− dotnetPackages, gnome3, curl, unzip, which, python
4−}:
1+/* This file defines all OpenRA packages under `openraPackages`,
2+ e.g. the OpenRA release engine can be found at `openraPackages.engines.release` (see `engines.nix`),
3+ or the out-of-tree mod "Combined Arms" can be found at `openraPackages.mods.ca` (see `mods.nix`).
4+ The `openra` package is just an alias to `openraPackages.engines.release`,
5+ and just provides the mods included in the source code of the engine.
6+ Additional engines or mods can be added with `openraPackages.buildOpenRAEngine` (function around `engine.nix`)
7+ and `openraPackages.buildOpenRAMod` (function around `mod.nix`), respectively.
8+*/
9+pkgs:
510
6−stdenv.mkDerivation rec {
7− pname = "openra";
8− version = "20181215";
11+with pkgs.lib;
912
10− meta = with stdenv.lib; {
11− description = "Real Time Strategy game engine recreating the C&C titles";
12− homepage = "http://www.openra.net/";
13− maintainers = [ maintainers.rardiol ];
14− license = licenses.gpl3;
15− platforms = platforms.linux;
16− };
13+let
14+ /* Building an engine or out-of-tree mod is very similar,
15+ but different enough not to be able to build them with the same package definition,
16+ so instaed we define what is common between them in a seperate file.
1717
18− src = fetchFromGitHub {
19− owner = "OpenRA";
20− repo = "OpenRA";
21− rev = "release-${version}";
22− sha256 = "0p0izykjnz7pz02g2khp7msqa00jhjsrzk9y0g29dirmdv75qa4r";
18+ Although `callPackage` could be used, it would require undoing `makeOverridable`,
19+ because `common.nix` does not define a package, but just an attribute set,
20+ which is directly passed as part of the argument to the engines and mods `callPackage`,
21+ so either the attributes added by `makeOverridable` have to be removed
22+ or the engine and mod package definitions will need to add `...` to the argument list.
23+ */
24+ common = let f = import ./common.nix; in f (builtins.intersectAttrs (functionArgs f) pkgs // {
25+ lua = pkgs.lua5_1;
26+ # It is not necessary to run the game, but it is nicer to be given an error dialog in the case of failure,
27+ # rather than having to look to the logs why it is not starting.
28+ inherit (pkgs.gnome3) zenity;
29+ });
2330
31+ /* Building a set of engines or mods requires some dependencies as well,
32+ so the sets will actually be defined as a function instead,
33+ requiring the dependencies and returning the actual set.
34+
35+ Not all dependencies for defining a engine or mod set are shared,
36+ so additional arguments can be passed as well.
37+
38+ The builders for engines and mods allow to delay specifying the name,
39+ by returning a function that expects a name, which we use, in this case,
40+ to base the name on the attribute name instead, preventing the need to specify the name twice
41+ if the attribute name and engine/mod name are equal.
42+ */
43+ callWithName = name: value: if isFunction value then value name else value;
44+ buildOpenRASet = f: args: pkgs.recurseIntoAttrs (mapAttrs callWithName (f ({
45+ inherit (pkgs) fetchFromGitHub;
46+ abbrevCommit = commit: substring 0 7 commit;
2447 extraPostFetch = ''
25− sed -i 's,curl,curl --insecure,g' $out/thirdparty/{fetch-thirdparty-deps,noget}.sh
48+ sed -i 's/curl/curl --insecure/g' $out/thirdparty/{fetch-thirdparty-deps,noget}.sh
2649 $out/thirdparty/fetch-thirdparty-deps.sh
2750 '';
28− };
29−
30− dontStrip = true;
31−
32− buildInputs = (with dotnetPackages;
33− [ NUnit3 NewtonsoftJson MonoNat FuzzyLogicLibrary SmartIrc4net SharpZipLib MaxMindGeoIP2 MaxMindDb SharpFont StyleCopMSBuild StyleCopPlusMSBuild RestSharp NUnitConsole OpenNAT ])
34− ++ [ curl unzip lua gnome3.zenity ];
35− nativeBuildInputs = [ curl unzip mono makeWrapper lua pkgconfig ];
36−
37− postPatch = ''
38− mkdir Support
39− sed -i \
40− -e 's/^VERSION.*/VERSION = release-${version}/g' \
41− -e '/GeoLite2-Country.mmdb.gz/d' \
42− -e '/fetch-geoip-db.sh/d' \
43− Makefile
44− substituteInPlace thirdparty/configure-native-deps.sh --replace "locations=\"" "locations=\"${lua}/lib "
45− '';
46−
47− preConfigure = ''
48− makeFlags="prefix=$out"
49− make version
50− '';
51−
52− buildFlags = [ "DEBUG=false" "default" "man-page" ];
53−
54− doCheck = true;
55−
56− #TODO: check
57− checkTarget = "nunit test";
51+ } // args)));
5852
59− installTargets = [ "install" "install-linux-icons" "install-linux-desktop" "install-linux-appdata" "install-linux-mime" "install-man-page" ];
53+in pkgs.recurseIntoAttrs rec {
54+ # The whole attribute set is destructered to ensure those (and only those) attributes are given
55+ # and to provide defaults for those that are optional.
56+ buildOpenRAEngine = { name ? null, version, description, homepage, mods, src }@engine:
57+ # Allow specifying the name at a later point if no name has been given.
58+ let builder = name: pkgs.callPackage ./engine.nix (common // {
59+ engine = engine // { inherit name; };
60+ }); in if name == null then builder else builder name;
6061
61− postInstall = with stdenv.lib; let
62− runtime = makeLibraryPath [ SDL2 freetype openal systemd lua ];
63− binaries= makeBinPath [ which mono gnome3.zenity python ];
64− in ''
65− wrapProgram $out/lib/openra/launch-game.sh \
66− --prefix PATH : "${binaries}" \
67− --prefix LD_LIBRARY_PATH : "${runtime}" \
68− --set TERM "xterm"
62+ # See `buildOpenRAEngine`.
63+ buildOpenRAMod = { name ? null, version, title, description, homepage, src, engine, assetsError ? "" }@mod: ({ version, mods ? [], src }@engine:
64+ let builder = name: pkgs.callPackage ./mod.nix (common // {
65+ mod = mod // { inherit name assetsError; };
66+ engine = engine // { inherit mods; };
67+ }); in if name == null then builder else builder name) engine;
6968
70− mkdir -p $out/bin
71− makeWrapper $out/lib/openra/launch-game.sh $out/bin/openra --run "cd $out/lib/openra"
72− printf "#!/bin/sh\nexec $out/bin/openra Game.Mod=ra" > $out/bin/openra-ra
73− chmod +x $out/bin/openra-ra
74− printf "#!/bin/sh\nexec $out/bin/openra Game.Mod=cnc" > $out/bin/openra-cnc
75− chmod +x $out/bin/openra-cnc
76− printf "#!/bin/sh\nexec $out/bin/openra Game.Mod=d2k" > $out/bin/openra-d2k
77− chmod +x $out/bin/openra-d2k
78− '';
69+ # See `buildOpenRASet`.
70+ engines = buildOpenRASet (import ./engines.nix) { inherit buildOpenRAEngine; };
71+ mods = buildOpenRASet (import ./mods.nix) { inherit buildOpenRAMod; };
7972}
pkgs/games/openra/engine.nixnew file+60
@@ -0,0 +1,60 @@
1+/* The package defintion for an OpenRA engine.
2+ It shares code with `mod.nix` by what is defined in `common.nix`.
3+ Similar to `mod.nix` it is a generic package definition,
4+ in order to make it easy to define multiple variants of the OpenRA engine.
5+ For each mod provided by the engine, a wrapper script is created,
6+ matching the naming convention used by `mod.nix`.
7+ This package could be seen as providing a set of in-tree mods,
8+ while the `mod.nix` pacakges provide a single out-of-tree mod.
9+*/
10+{ stdenv
11+, packageAttrs
12+, patchEngine
13+, wrapLaunchGame
14+, engine
15+}:
16+
17+with stdenv.lib;
18+
19+stdenv.mkDerivation (recursiveUpdate packageAttrs rec {
20+ name = "${pname}-${version}";
21+ pname = "openra";
22+ version = "${engine.name}-${engine.version}";
23+
24+ src = engine.src;
25+
26+ postPatch = patchEngine "." version;
27+
28+ configurePhase = ''
29+ runHook preConfigure
30+
31+ make version VERSION=${escapeShellArg version}
32+
33+ runHook postConfigure
34+ '';
35+
36+ buildFlags = [ "DEBUG=false" "default" "man-page" ];
37+
38+ checkTarget = "nunit test";
39+
40+ installTargets = [
41+ "install"
42+ "install-linux-icons"
43+ "install-linux-desktop"
44+ "install-linux-appdata"
45+ "install-linux-mime"
46+ "install-man-page"
47+ ];
48+
49+ postInstall = ''
50+ ${wrapLaunchGame ""}
51+
52+ ${concatStrings (map (mod: ''
53+ makeWrapper $out/bin/openra $out/bin/openra-${mod} --add-flags Game.Mod=${mod}
54+ '') engine.mods)}
55+ '';
56+
57+ meta = {
58+ inherit (engine) description homepage;
59+ };
60+})
pkgs/games/openra/engines.nixnew file+41
@@ -0,0 +1,41 @@
1+{ buildOpenRAEngine, fetchFromGitHub, abbrevCommit, extraPostFetch }:
2+
3+let
4+ buildUpstreamOpenRAEngine = { version, rev, sha256 }: name: (buildOpenRAEngine {
5+ inherit version;
6+ description = "Open-source re-implementation of Westwood Studios' 2D Command and Conquer games";
7+ homepage = https://www.openra.net/;
8+ mods = [ "cnc" "d2k" "ra" "ts" ];
9+ src = fetchFromGitHub {
10+ owner = "OpenRA";
11+ repo = "OpenRA" ;
12+ inherit rev sha256 extraPostFetch;
13+ };
14+ } name).overrideAttrs (oldAttrs: {
15+ postInstall = ''
16+ ${oldAttrs.postInstall}
17+ cp -r mods/ts $out/lib/openra/mods/
18+ cp mods/ts/icon.png $(mkdirp $out/share/pixmaps)/openra-ts.png
19+ ( cd $out/share/applications; sed -e 's/Dawn/Sun/g' -e 's/cnc/ts/g' openra-cnc.desktop > openra-ts.desktop )
20+ '';
21+ });
22+
23+in {
24+ release = buildUpstreamOpenRAEngine rec {
25+ version = "20181215";
26+ rev = "release-${version}";
27+ sha256 = "0p0izykjnz7pz02g2khp7msqa00jhjsrzk9y0g29dirmdv75qa4r";
28+ };
29+
30+ playtest = buildUpstreamOpenRAEngine rec {
31+ version = "20190106";
32+ rev = "playtest-${version}";
33+ sha256 = "0ps9x379plrrj1hnj4fpr26lc46mzgxknv5imxi0bmrh5y4781ql";
34+ };
35+
36+ bleed = let commit = "6de92de8d982094a766eab97a92225c240d85493"; in buildUpstreamOpenRAEngine {
37+ version = abbrevCommit commit;
38+ rev = commit;
39+ sha256 = "0p0izykjnz7pz02g2khp7msqa00jhjsrzk9y0g29dirmdv75qa4r";
40+ };
41+}
pkgs/games/openra/mkdirp.shnew file+4
@@ -0,0 +1,4 @@
1+mkdirp() {
2+ mkdir -p "$@"
3+ echo "$@"
4+}
pkgs/games/openra/mod-launch-game.shnew file+25
@@ -0,0 +1,25 @@
1+#!/bin/sh
2+show_error() {
3+ if command -v zenity > /dev/null; then
4+ zenity --no-wrap --no-markup --error --title "OpenRA - @title@" --text "$1" 2>/dev/null
5+ else
6+ printf "$1\n" >&2
7+ fi
8+ exit 1
9+}
10+
11+cd "@out@/lib/openra-@name@"
12+
13+# Check for missing assets
14+assetsError='@assetsError@'
15+if [ -n "$assetsError" -a ! -d "$HOME/.openra/Content/@name@" ]; then
16+ show_error "$assetsError"
17+fi
18+
19+# Run the game
20+mono --debug OpenRA.Game.exe Game.Mod=@name@ Engine.LaunchPath="@out@/bin/openra-@name@" Engine.ModSearchPaths="@out@/lib/openra-@name@/mods" "$@"
21+
22+# Show a crash dialog if something went wrong
23+if [ $? -ne 0 -a $? -ne 1 ]; then
24+ show_error "OpenRA - @title@ has encountered a fatal error.\nPlease refer to the crash logs for more information.\n\nLog files are located in ~/.openra/Logs"
25+fi
pkgs/games/openra/mod.nixnew file+104
@@ -0,0 +1,104 @@
1+/* The package defintion for an OpenRA out-of-tree mod.
2+ It shares code with `engine.nix` by what is defined in `common.nix`.
3+ To build an out-of-tree mod it needs the source code of the engine available,
4+ and they each need to be build with a specific version or fork of the engine,
5+ so the engine needs to be supplied as an argument as well.
6+ The engine is relatively small and quick to build, so this is not much of a problem.
7+ Building a mod will result in a wrapper script that starts the mod inside the specified engine.
8+*/
9+{ stdenv
10+, packageAttrs
11+, patchEngine
12+, wrapLaunchGame
13+, mod
14+, engine
15+}:
16+
17+with stdenv.lib;
18+
19+let
20+ engineSourceName = engine.src.name or "engine";
21+ modSourceName = mod.src.name or "mod";
22+
23+# Based on: https://build.opensuse.org/package/show/home:fusion809/openra-ura
24+in stdenv.mkDerivation (recursiveUpdate packageAttrs rec {
25+ name = "${pname}-${version}";
26+ pname = "openra-${mod.name}";
27+ inherit (mod) version;
28+
29+ srcs = [
30+ mod.src
31+ engine.src
32+ ];
33+
34+ sourceRoot = ".";
35+
36+ postUnpack = ''
37+ mv ${engineSourceName} ${modSourceName}
38+ cd ${modSourceName}
39+ '';
40+
41+ postPatch = ''
42+ cat <<'EOF' > fetch-engine.sh
43+ #!/bin/sh
44+ exit 0
45+ EOF
46+
47+ sed -i 's/^VERSION.*/VERSION = ${version}/g' Makefile
48+
49+ dos2unix *.md
50+
51+ ${patchEngine engineSourceName engine.version}
52+ '';
53+
54+ configurePhase = ''
55+ runHook preConfigure
56+
57+ make version VERSION=${escapeShellArg version}
58+ make -C ${engineSourceName} version VERSION=${escapeShellArg engine.version}
59+
60+ runHook postConfigure
61+ '';
62+
63+ checkTarget = "test";
64+
65+ installPhase = ''
66+ runHook preInstall
67+
68+ make -C ${engineSourceName} install-engine install-common-mod-files DATA_INSTALL_DIR=$out/lib/${pname}
69+
70+ cp -r ${engineSourceName}/mods/{${concatStringsSep "," ([ "common" "modcontent" ] ++ engine.mods)}} mods/${mod.name} \
71+ $out/lib/${pname}/mods/
72+
73+ substitute ${./mod-launch-game.sh} $out/lib/${pname}/launch-game.sh \
74+ --subst-var out \
75+ --subst-var-by name ${escapeShellArg mod.name} \
76+ --subst-var-by title ${escapeShellArg mod.title} \
77+ --subst-var-by assetsError ${escapeShellArg mod.assetsError}
78+ chmod +x $out/lib/${pname}/launch-game.sh
79+
80+ ${wrapLaunchGame "-${mod.name}"}
81+
82+ substitute ${./openra-mod.desktop} $(mkdirp $out/share/applications)/${pname}.desktop \
83+ --subst-var-by name ${escapeShellArg mod.name} \
84+ --subst-var-by title ${escapeShellArg mod.title}
85+
86+ cp README.md $(mkdirp $out/share/doc/packages/${pname})/README.md
87+
88+ [[ -e mods/${mod.name}/icon.png ]] && mod_icon=mods/${mod.name}/icon.png || {
89+ [[ -e mods/${mod.name}/logo.png ]] && mod_icon=mods/${mod.name}/logo.png || mod_icon=packaging/linux/mod_256x256.png
90+ }
91+ cp "$mod_icon" $(mkdirp $out/share/pixmaps)/${pname}.png
92+
93+ for size in 16 32 48 64 128 256; do
94+ size=''${size}x''${size}
95+ cp packaging/linux/mod_''${size}.png $(mkdirp $out/share/icons/hicolor/''${size}/apps)/${pname}.png
96+ done
97+
98+ runHook postInstall
99+ '';
100+
101+ meta = {
102+ inherit (mod) description homepage;
103+ };
104+})
pkgs/games/openra/mods.nixnew file+339
@@ -0,0 +1,339 @@
1+{ buildOpenRAMod, fetchFromGitHub, abbrevCommit, extraPostFetch }:
2+
3+let
4+ unsafeBuildOpenRAMod = attrs: name: (buildOpenRAMod attrs name).overrideAttrs (_: {
5+ doCheck = false;
6+ });
7+
8+in {
9+ ca = buildOpenRAMod {
10+ version = "93";
11+ title = "Combined Arms";
12+ description = "A game that combines units from the official OpenRA Red Alert and Tiberian Dawn mods";
13+ homepage = https://github.com/Inq8/CAmod;
14+ src = fetchFromGitHub {
15+ owner = "Inq8";
16+ repo = "CAmod";
17+ rev = "16fb77d037be7005c3805382712c33cec1a2788c";
18+ sha256 = "11fjyr3692cy2a09bqzk5ya1hf6plh8hmdrgzds581r9xbj0q4pr";
19+ };
20+ engine = let commit = "b8a7dd52ff893ed8225726d4ed4e14ecad748404"; in {
21+ version = abbrevCommit commit;
22+ src = fetchFromGitHub {
23+ owner = "Inq8";
24+ repo = "CAengine" ;
25+ rev = commit;
26+ sha256 = "0dyk861qagibx8ldshz7d2nrki9q550f6f0wy8pvayvf1gv1dbxj";
27+ name = "engine";
28+ inherit extraPostFetch;
29+ };
30+ };
31+ };
32+
33+ d2 = unsafeBuildOpenRAMod rec {
34+ version = "128";
35+ title = "Dune II";
36+ description = "A modernization of the original ${title} game";
37+ homepage = https://github.com/OpenRA/d2;
38+ src = fetchFromGitHub {
39+ owner = "OpenRA";
40+ repo = "d2";
41+ rev = "bc969207b532a2def69e0d6ac09a4e8fb5d4e946";
42+ sha256 = "18v154kf1fmfk2gnymb3ggsfy73ql8rr7jvbhiw60yhzwx89cdk8";
43+ };
44+ engine = rec {
45+ version = "20181215";
46+ mods = [ "cnc" "d2k" "ra" ];
47+ src = fetchFromGitHub {
48+ owner = "OpenRA";
49+ repo = "OpenRA" ;
50+ rev = "release-${version}";
51+ sha256 = "0p0izykjnz7pz02g2khp7msqa00jhjsrzk9y0g29dirmdv75qa4r";
52+ name = "engine";
53+ inherit extraPostFetch;
54+ };
55+ };
56+ assetsError = ''
57+ The mod expects the original ${title} game assets in place:
58+ https://github.com/OpenRA/d2/wiki
59+ '';
60+ };
61+
62+ dr = buildOpenRAMod rec {
63+ version = "244";
64+ title = "Dark Reign";
65+ description = "A re-imagination of the original Command & Conquer: ${title} game";
66+ homepage = https://github.com/drogoganor/DarkReign;
67+ src = fetchFromGitHub {
68+ owner = "drogoganor";
69+ repo = "DarkReign";
70+ rev = "e21db398f4d995c91b9e1a0f31ffaa7d54f43742";
71+ sha256 = "1gzvdf6idmx0rr8afaxd9dsbnxljif2kic6znkd9vcrwnqmp1fjr";
72+ };
73+ engine = let commit = "7fcfb1dcb2bd472fa6680ffa37bd3bbedb2c44c5"; in {
74+ version = abbrevCommit commit;
75+ src = fetchFromGitHub {
76+ owner = "drogoganor";
77+ repo = "OpenRA" ;
78+ rev = commit;
79+ sha256 = "0x7k96j3q16dgay4jjlyv9kcgn4sc4v9ksw6ijnjws7q1r2rjs0m";
80+ name = "engine";
81+ inherit extraPostFetch;
82+ };
83+ };
84+ };
85+
86+ gen = buildOpenRAMod {
87+ version = "1133";
88+ title = "Generals Alpha";
89+ description = "Re-imagination of the original Command & Conquer: Generals game";
90+ homepage = https://github.com/MustaphaTR/Generals-Alpha;
91+ src = fetchFromGitHub {
92+ owner = "MustaphaTR";
93+ repo = "Generals-Alpha";
94+ rev = "277d20d5a8b5e11eac9443031af133dc110c653f";
95+ sha256 = "1k37545l99q7zphnh1ykvimsyp5daykannps07d4dgr2w9l7bmhg";
96+ };
97+ engine = rec {
98+ version = "gen-20180905";
99+ src = fetchFromGitHub {
100+ owner = "MustaphaTR";
101+ repo = "OpenRA" ;
102+ rev = version;
103+ sha256 = "0wy1h7fg0n8dpy6y91md7x0qnr9rk4xf6155jali4bi8gghw2g5v";
104+ name = "generals-alpha-engine";
105+ inherit extraPostFetch;
106+ };
107+ };
108+ };
109+
110+ kknd = buildOpenRAMod rec {
111+ version = "142";
112+ title = "Krush, Kill 'n' Destroy";
113+ description = "Re-imagination of the original ${title} game";
114+ homepage = https://kknd-game.com/;
115+ src = fetchFromGitHub {
116+ owner = "IceReaper";
117+ repo = "KKnD";
118+ rev = "54d34292168d5c47529688c8d5ca7693c4001ef3";
119+ sha256 = "1rsdig282cfr8b4iamr9ri6sshgppp8gllfyib6c2hvqqr301720";
120+ };
121+ engine = let commit = "4e8eab4ca00d1910203c8a103dfd2c002714daa8"; in {
122+ version = abbrevCommit commit;
123+ src = fetchFromGitHub {
124+ owner = "OpenRA";
125+ repo = "OpenRA" ;
126+ rev = commit;
127+ sha256 = "1yyqparf93x8yzy1f46gsymgkj5jls25v2yc7ighr3f7mi3igdvq";
128+ name = "engine";
129+ inherit extraPostFetch;
130+ };
131+ };
132+ };
133+
134+ mw = buildOpenRAMod rec {
135+ version = "235";
136+ title = "Medieval Warfare";
137+ description = "A re-imagination of the original Command & Conquer: ${title} game";
138+ homepage = https://github.com/CombinE88/Medieval-Warfare;
139+ src = fetchFromGitHub {
140+ owner = "CombinE88";
141+ repo = "Medieval-Warfare";
142+ rev = "1e4fc7ea24d0806c5a7cd753490e967d804a3567";
143+ sha256 = "0swa66mzb6wr8vf1yivrss54dl98jzzwh9b8qrjfwmfrq2i356iq";
144+ };
145+ engine = let commit = "9f9617aa359ebc1923252b7a4a79def73ecfa8a2"; in {
146+ version = abbrevCommit commit;
147+ src = fetchFromGitHub {
148+ owner = "CombinE88";
149+ repo = "OpenRA" ;
150+ rev = commit;
151+ sha256 = "02h29xnc1cb5zr001cnmaww5qnfnfaza4v28251jgzkby593r32q";
152+ name = "engine";
153+ inherit extraPostFetch;
154+ };
155+ };
156+ };
157+
158+ ra2 = buildOpenRAMod rec {
159+ version = "876";
160+ title = "Red Alert 2";
161+ description = "Re-imagination of the original Command & Conquer: ${title} game";
162+ homepage = https://github.com/OpenRA/ra2;
163+ src = fetchFromGitHub {
164+ owner = "OpenRA";
165+ repo = "ra2";
166+ rev = "6a864b2a5887ae42291768fb3dec73082fee44ee";
167+ sha256 = "19m4z9r00dj67746ps2f9a8i1icq8nm0iiww6dl975yl6gaxp5qy";
168+ };
169+ engine = rec {
170+ version = "20180923";
171+ src = fetchFromGitHub {
172+ owner = "OpenRA";
173+ repo = "OpenRA" ;
174+ rev = "release-${version}";
175+ sha256 = "1pgi3zaq9fwwdq6yh19bwxscslqgabjxkvl9bcn1a5agy4bfbqk5";
176+ name = "engine";
177+ inherit extraPostFetch;
178+ };
179+ };
180+ assetsError = ''
181+ The mod expects the original ${title} game assets in place:
182+ https://github.com/OpenRA/ra2/wiki
183+ '';
184+ };
185+
186+ raclassic = buildOpenRAMod {
187+ version = "171";
188+ title = "Red Alert Classic";
189+ description = "A modernization of the original Command & Conquer: Red Alert game";
190+ homepage = https://github.com/OpenRA/raclassic;
191+ src = fetchFromGitHub {
192+ owner = "OpenRA";
193+ repo = "raclassic";
194+ rev = "a2319b3dfb367a8d4278bf7baf55a10abf615fbc";
195+ sha256 = "1k67fx4d9hg8mckzp7pp8lxa6ngqxnnrnbqyfls99dqc4df1iw0a";
196+ };
197+ engine = rec {
198+ version = "20181215";
199+ src = fetchFromGitHub {
200+ owner = "OpenRA";
201+ repo = "OpenRA" ;
202+ rev = "release-${version}";
203+ sha256 = "0p0izykjnz7pz02g2khp7msqa00jhjsrzk9y0g29dirmdv75qa4r";
204+ name = "engine";
205+ inherit extraPostFetch;
206+ };
207+ };
208+ };
209+
210+ rv = unsafeBuildOpenRAMod {
211+ version = "1294";
212+ title = "Romanov's Vengeance";
213+ description = "Re-imagination of the original Command & Conquer: Red Alert 2 game";
214+ homepage = https://github.com/MustaphaTR/Romanovs-Vengeance;
215+ src = fetchFromGitHub {
216+ owner = "MustaphaTR";
217+ repo = "Romanovs-Vengeance";
218+ rev = "c21cb11579d7e12354c5ccb5c3c47e567c6b3d4f";
219+ sha256 = "1vmc5b9awx8q0mahwv11fzgplw9w7m8kzvnx5cl7xr1w5wk87428";
220+ };
221+ engine = let commit = "e9e99074b294c32fbe88dd8727581cb8c512c2e2"; in {
222+ version = abbrevCommit commit;
223+ mods = [ "as" ];
224+ src = fetchFromGitHub {
225+ owner = "GraionDilach";
226+ repo = "OpenRA" ;
227+ rev = commit;
228+ sha256 = "0bibnakpmbxwglf2dka6g04xp8dzwyms1zk5kqlbm8gpdp0aqmxp";
229+ name = "engine";
230+ inherit extraPostFetch;
231+ };
232+ };
233+ assetsError = ''
234+ The mod expects the Command & Conquer: The Ultimate Collection assets in place:
235+ https://github.com/OpenRA/ra2/wiki
236+ '';
237+ };
238+
239+ sp = unsafeBuildOpenRAMod {
240+ version = "153";
241+ title = "Shattered Paradise";
242+ description = "Re-imagination of the original Command & Conquer: Tiberian Sun game";
243+ homepage = https://github.com/ABrandau/OpenRAModSDK;
244+ src = fetchFromGitHub {
245+ owner = "ABrandau";
246+ repo = "OpenRAModSDK";
247+ rev = "89148b8cf89bf13911fafb74a1aa2b4cacf027e0";
248+ sha256 = "1bb8hzd3mhnn76iqiah1161qz98f0yvyryhmrghq03xlbin3mhbi";
249+ };
250+ engine = let commit = "82a2f234bdf3b768cea06408e3de30f9fbbe9412"; in {
251+ version = abbrevCommit commit;
252+ mods = [ "as" "ts" ];
253+ src = fetchFromGitHub {
254+ owner = "ABrandau";
255+ repo = "OpenRA" ;
256+ rev = commit;
257+ sha256 = "1nl3brvx1bikxm5rmpc7xmd32n722jiyjh86pnar6b6idr1zj2ws";
258+ name = "engine";
259+ inherit extraPostFetch;
260+ };
261+ };
262+ };
263+
264+ ss = buildOpenRAMod rec {
265+ version = "72";
266+ title = "Sole Survivor";
267+ description = "A re-imagination of the original Command & Conquer: ${title} game";
268+ homepage = https://github.com/MustaphaTR/sole-survivor;
269+ src = fetchFromGitHub {
270+ owner = "MustaphaTR";
271+ repo = "sole-survivor";
272+ rev = "fad65579c8b487cef9a8145e872390ed77c16c69";
273+ sha256 = "0h7is7x2qyvq7vqp0jgw5zrdkw8g7ndd82d843ldhnb0a3vyrk34";
274+ };
275+ engine = let commit = "becfc154c5cd3891d695339ff86883db8b5790a5"; in {
276+ version = abbrevCommit commit;
277+ src = fetchFromGitHub {
278+ owner = "OpenRA";
279+ repo = "OpenRA" ;
280+ rev = commit;
281+ sha256 = "0id8vf3cjr7h5pz4sw8pdaz3sc45lxr21k1fk4309kixsrpa7i0y";
282+ name = "engine";
283+ inherit extraPostFetch;
284+ };
285+ };
286+ };
287+
288+ ura = buildOpenRAMod {
289+ version = "431";
290+ title = "Red Alert Unplugged";
291+ description = "Re-imagination of the original Command & Conquer: Red Alert game";
292+ homepage = http://redalertunplugged.com/;
293+ src = fetchFromGitHub {
294+ owner = "RAunplugged";
295+ repo = "uRA";
296+ rev = "128dc53741fae923f4af556f2293ceaa0cf571f0";
297+ sha256 = "1mhr8kyh313z52gdrqv31d6z7jvdldiajalca5mcr8gzg6mph66p";
298+ };
299+ engine = rec {
300+ version = "unplugged-cd82382";
301+ src = fetchFromGitHub {
302+ owner = "RAunplugged";
303+ repo = "OpenRA" ;
304+ rev = version;
305+ sha256 = "1p5hgxxvxlz8480vj0qkmnxjh7zj3hahk312m0zljxfdb40652w1";
306+ name = "engine";
307+ inherit extraPostFetch;
308+ };
309+ };
310+ };
311+
312+ yr = unsafeBuildOpenRAMod rec {
313+ version = "117";
314+ homepage = https://github.com/cookgreen/yr;
315+ title = "Yuri's Revenge";
316+ description = "Re-imagination of the original Command & Conquer: ${title} game";
317+ src = fetchFromGitHub {
318+ owner = "cookgreen";
319+ repo = "yr";
320+ rev = "1d4beeb0687fe4b39b01ec31f3702cfb90a7f4f7";
321+ sha256 = "1rd962ja1x72rz68kbmp19yiip3iif50hzlj3v8k1f5l94r2x2pn";
322+ };
323+ engine = rec {
324+ version = "20180923";
325+ src = fetchFromGitHub {
326+ owner = "OpenRA";
327+ repo = "OpenRA" ;
328+ rev = "release-${version}";
329+ sha256 = "1pgi3zaq9fwwdq6yh19bwxscslqgabjxkvl9bcn1a5agy4bfbqk5";
330+ name = "engine";
331+ inherit extraPostFetch;
332+ };
333+ };
334+ assetsError = ''
335+ The mod expects the Command & Conquer: The Ultimate Collection assets in place:
336+ https://github.com/OpenRA/ra2/wiki
337+ '';
338+ };
339+}
pkgs/games/openra/openra-mod.desktopnew file+11
@@ -0,0 +1,11 @@
1+[Desktop Entry]
2+Type=Application
3+Version=1.0
4+Name=OpenRA - @title@
5+GenericName=Real Time Strategy Game
6+GenericName[de]=Echtzeit-Strategiespiel
7+Comment=@description@
8+Icon=openra-@name@
9+Exec=openra-@name@
10+Terminal=false
11+Categories=Game;StrategyGame;X-RTS;X-RealTimeStrategy;X-RealTimeStrategyGame;
pkgs/games/openra/packages.nixnew file+60
@@ -0,0 +1,60 @@
1+pkgs:
2+
3+let
4+ /* Building an engine or out-of-tree mod is very similar,
5+ but different enough not to be able to build them with the same package definition,
6+ so instaed we define what is common between them in a seperate file.
7+
8+ Although `callPackage` could be used, it would require undoing `makeOverridable`,
9+ because `common.nix` does not define a package, but just an attribute set,
10+ which is directly passed as part of the argument to the engines and mods `callPackage`,
11+ so either the attributes added by `makeOverridable` have to be removed
12+ or the engine and mod package definitions will need to add `...` to the argument list.
13+ */
14+ common = let f = import ./common.nix; in f (builtins.intersectAttrs (builtins.functionArgs f) pkgs // {
15+ lua = pkgs.lua5_1;
16+ # It is not necessary to run the game, but it is nicer to be given an error dialog in the case of failure,
17+ # rather than having to look to the logs why it is not starting.
18+ inherit (pkgs.gnome3) zenity;
19+ });
20+
21+ /* Building a set of engines or mods requires some dependencies as well,
22+ so the sets will actually be defined as a function instead,
23+ requiring the dependencies and returning the actual set.
24+
25+ Not all dependencies for defining a engine or mod set are shared,
26+ so additional arguments can be passed as well.
27+
28+ The builders for engines and mods allow to delay specifying the name,
29+ by returning a function that expects a name, which we use, in this case,
30+ to base the name on the attribute name instead, preventing the need to specify the name twice
31+ if the attribute name and engine/mod name are equal.
32+ */
33+ buildOpenRASet = f: args: builtins.mapAttrs (name: value: if builtins.isFunction value then value name else value) (f ({
34+ inherit (pkgs) fetchFromGitHub;
35+ extraPostFetch = ''
36+ sed -i 's/curl/curl --insecure/g' $out/thirdparty/{fetch-thirdparty-deps,noget}.sh
37+ $out/thirdparty/fetch-thirdparty-deps.sh
38+ '';
39+ } // args));
40+
41+in rec {
42+ # The whole attribute set is destructered to ensure those (and only those) attributes are given
43+ # and to provide defaults for those that are optional.
44+ buildOpenRAEngine = { name ? null, version, description, homepage, mods, src, installExperimental ? "" }@engine:
45+ # Allow specifying the name at a later point if no name has been given.
46+ let builder = name: pkgs.callPackage ./engine.nix (common // {
47+ engine = engine // { inherit name installExperimental; };
48+ }); in if name == null then builder else builder name;
49+
50+ # See `buildOpenRAEngine`.
51+ buildOpenRAMod = { name ? null, version, title, description, homepage, src, engine }@mod: ({ version, mods ? [], src }@engine:
52+ let builder = name: pkgs.callPackage ./mod.nix (common // {
53+ mod = mod // { inherit name; };
54+ engine = engine // { inherit mods; };
55+ }); in if name == null then builder else builder name) engine;
56+
57+ # See `buildOpenRASet`.
58+ engines = buildOpenRASet (import ./engines.nix) { inherit buildOpenRAEngine; };
59+ mods = buildOpenRASet (import ./mods.nix) { inherit buildOpenRAMod; };
60+}
pkgs/top-level/all-packages.nix+3−1
@@ -20817,7 +20817,9 @@ in
2081720817
2081820818 openmw-tes3mp = libsForQt5.callPackage ../games/openmw/tes3mp.nix { };
2081920819
20820− openra = callPackage ../games/openra { lua = lua5_1; };
20820+ openraPackages = import ../games/openra pkgs;
20821+
20822+ openra = openraPackages.engines.release;
2082120823
2082220824 openrw = callPackage ../games/openrw { };
2082320825