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.
18 engineSourceName = engine.src.name or "engine";
19 modSourceName = mod.src.name or "mod";
21 # Based on: https://build.opensuse.org/package/show/home:fusion809/openra-ura
22 in stdenv.mkDerivation (lib.recursiveUpdate packageAttrs rec {
23 name = "${pname}-${version}";
24 pname = "openra_2019-${mod.name}";
25 inherit (mod) version;
35 mv ${engineSourceName} ${modSourceName}
40 cat <<'EOF' > fetch-engine.sh
45 sed -i 's/^VERSION.*/VERSION = ${version}/g' Makefile
49 ${patchEngine engineSourceName engine.version}
55 make version VERSION=${lib.escapeShellArg version}
56 make -C ${engineSourceName} version VERSION=${lib.escapeShellArg engine.version}
66 make -C ${engineSourceName} install-engine install-common-mod-files DATA_INSTALL_DIR=$out/lib/${pname}
68 cp -r ${engineSourceName}/mods/{${lib.concatStringsSep "," ([ "common" "modcontent" ] ++ engine.mods)}} mods/* \
69 $out/lib/${pname}/mods/
71 substitute ${./mod-launch-game.sh} $out/lib/openra_2019-${mod.name}/launch-game.sh \
73 --subst-var-by name ${lib.escapeShellArg mod.name} \
74 --subst-var-by title ${lib.escapeShellArg mod.title} \
75 --subst-var-by assetsError ${lib.escapeShellArg mod.assetsError}
76 chmod +x $out/lib/openra_2019-${mod.name}/launch-game.sh
78 ${wrapLaunchGame "_2019-${mod.name}" "openra-${mod.name}"}
80 substitute ${./openra-mod.desktop} $(mkdirp $out/share/applications)/${pname}.desktop \
81 --subst-var-by name ${lib.escapeShellArg mod.name} \
82 --subst-var-by title ${lib.escapeShellArg mod.title} \
83 --subst-var-by description ${lib.escapeShellArg mod.description}
85 cp README.md $(mkdirp $out/share/doc/packages/${pname})/README.md
87 [[ -e mods/${mod.name}/icon.png ]] && mod_icon=mods/${mod.name}/icon.png || {
88 [[ -e mods/${mod.name}/logo.png ]] && mod_icon=mods/${mod.name}/logo.png || mod_icon=packaging/linux/mod_256x256.png
90 cp "$mod_icon" $(mkdirp $out/share/pixmaps)/${pname}.png
92 for size in 16 32 48 64 128 256; do
93 size=''${size}x''${size}
94 cp packaging/linux/mod_''${size}.png $(mkdirp $out/share/icons/hicolor/''${size}/apps)/${pname}.png
101 inherit (mod) description homepage;