1/*
2 The package definition for an OpenRA engine.
3 It shares code with `mod.nix` by what is defined in `common.nix`.
4 Similar to `mod.nix` it is a generic package definition,
5 in order to make it easy to define multiple variants of the OpenRA engine.
6 For each mod provided by the engine, a wrapper script is created,
7 matching the naming convention used by `mod.nix`.
8 This package could be seen as providing a set of in-tree mods,
9 while the `mod.nix` packages provide a single out-of-tree mod.
10*/
11{
12 lib,
13 stdenv,
14 packageAttrs,
15 patchEngine,
16 wrapLaunchGame,
17 engine,
18}:
19
20stdenv.mkDerivation (
21 lib.recursiveUpdate packageAttrs rec {
22 pname = "openra_2019";
23 version = "${engine.name}-${engine.version}";
24
25 src = engine.src;
26
27 postPatch = patchEngine "." version;
28
29 configurePhase = ''
30 runHook preConfigure
31
32 make version VERSION=${lib.escapeShellArg version}
33
34 runHook postConfigure
35 '';
36
37 buildFlags = [
38 "DEBUG=false"
39 "default"
40 "man-page"
41 ];
42
43 checkTarget = "nunit test";
44
45 installTargets = [
46 "install"
47 "install-linux-icons"
48 "install-linux-desktop"
49 "install-linux-appdata"
50 "install-linux-mime"
51 "install-man-page"
52 ];
53
54 postInstall = ''
55 ${wrapLaunchGame "" "openra"}
56
57 ${lib.concatStrings (
58 map (mod: ''
59 makeWrapper $out/bin/openra $out/bin/openra-${mod} --add-flags Game.Mod=${mod}
60 '') engine.mods
61 )}
62 '';
63
64 meta = {
65 inherit (engine) description homepage;
66 };
67 }
68)