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.
20 engineSourceName = engine.src.name or "engine";
21 modSourceName = mod.src.name or "mod";
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;
37 mv ${engineSourceName} ${modSourceName}
42 cat <<'EOF' > fetch-engine.sh
47 sed -i 's/^VERSION.*/VERSION = ${version}/g' Makefile
51 ${patchEngine engineSourceName engine.version}
57 make version VERSION=${escapeShellArg version}
58 make -C ${engineSourceName} version VERSION=${escapeShellArg engine.version}
68 make -C ${engineSourceName} install-engine install-common-mod-files DATA_INSTALL_DIR=$out/lib/${pname}
70 cp -r ${engineSourceName}/mods/{${concatStringsSep "," ([ "common" "modcontent" ] ++ engine.mods)}} mods/* \
71 $out/lib/${pname}/mods/
73 substitute ${./mod-launch-game.sh} $out/lib/${pname}/launch-game.sh \
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
80 ${wrapLaunchGame "-${mod.name}"}
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 --subst-var-by description ${escapeShellArg mod.description}
87 cp README.md $(mkdirp $out/share/doc/packages/${pname})/README.md
89 [[ -e mods/${mod.name}/icon.png ]] && mod_icon=mods/${mod.name}/icon.png || {
90 [[ -e mods/${mod.name}/logo.png ]] && mod_icon=mods/${mod.name}/logo.png || mod_icon=packaging/linux/mod_256x256.png
92 cp "$mod_icon" $(mkdirp $out/share/pixmaps)/${pname}.png
94 for size in 16 32 48 64 128 256; do
95 size=''${size}x''${size}
96 cp packaging/linux/mod_''${size}.png $(mkdirp $out/share/icons/hicolor/''${size}/apps)/${pname}.png
103 inherit (mod) description homepage;