about summary refs log tree commit diff
path: root/pkgs/games/openra/common.nix
diff options
context:
space:
mode:
authorMatthijs Steen <emailmatthijs@gmail.com>2019-01-02 01:05:51 +0100
committerMatthijs Steen <emailmatthijs@gmail.com>2019-01-09 20:57:29 +0100
commit1ae7384ddb3419330ab134da548dd8769b9f3d11 (patch)
treec3f3c1cea85037c6309f90beb5f2c8c66f2f577c /pkgs/games/openra/common.nix
parentde6d70f52e2acbc08d1e9db8c0f9af0a671d2137 (diff)
downloadnixlib-1ae7384ddb3419330ab134da548dd8769b9f3d11.tar
nixlib-1ae7384ddb3419330ab134da548dd8769b9f3d11.tar.gz
nixlib-1ae7384ddb3419330ab134da548dd8769b9f3d11.tar.bz2
nixlib-1ae7384ddb3419330ab134da548dd8769b9f3d11.tar.lz
nixlib-1ae7384ddb3419330ab134da548dd8769b9f3d11.tar.xz
nixlib-1ae7384ddb3419330ab134da548dd8769b9f3d11.tar.zst
nixlib-1ae7384ddb3419330ab134da548dd8769b9f3d11.zip
openra with extra mods
Diffstat (limited to 'pkgs/games/openra/common.nix')
-rw-r--r--pkgs/games/openra/common.nix87
1 files changed, 87 insertions, 0 deletions
diff --git a/pkgs/games/openra/common.nix b/pkgs/games/openra/common.nix
new file mode 100644
index 000000000000..e90f8170e18e
--- /dev/null
+++ b/pkgs/games/openra/common.nix
@@ -0,0 +1,87 @@
+/*  The reusable code, and package attributes, between OpenRA engine packages (engine.nix)
+    and out-of-tree mod packages (mod.nix).
+*/
+{ stdenv, makeSetupHook, curl, unzip, dos2unix, pkgconfig, makeWrapper
+, lua, mono, dotnetPackages, python
+, libGL, openal, SDL2
+, zenity
+}:
+
+with stdenv.lib;
+
+let
+  path = makeBinPath ([ mono python ] ++ optional (zenity != null) zenity);
+  rpath = makeLibraryPath [ lua openal SDL2 ];
+  mkdirp = makeSetupHook { } ./mkdirp.sh;
+
+in {
+  patchEngine = dir: version: ''
+    sed -i \
+      -e 's/^VERSION.*/VERSION = ${version}/g' \
+      -e '/fetch-geoip-db/d' \
+      -e '/GeoLite2-Country.mmdb.gz/d' \
+      ${dir}/Makefile
+
+    sed -i 's|locations=.*|locations=${lua}/lib|' ${dir}/thirdparty/configure-native-deps.sh
+  '';
+
+  wrapLaunchGame = openraSuffix: ''
+    # Setting TERM=xterm fixes an issue with terminfo in mono: System.Exception: Magic number is wrong: 542
+    # https://github.com/mono/mono/issues/6752#issuecomment-365212655
+    wrapProgram $out/lib/openra${openraSuffix}/launch-game.sh \
+      --prefix PATH : "${path}" \
+      --prefix LD_LIBRARY_PATH : "${rpath}" \
+      --set TERM xterm
+
+    makeWrapper $out/lib/openra${openraSuffix}/launch-game.sh $(mkdirp $out/bin)/openra${openraSuffix} \
+      --run "cd $out/lib/openra${openraSuffix}"
+  '';
+
+  packageAttrs = {
+    buildInputs = with dotnetPackages; [
+      FuzzyLogicLibrary
+      MaxMindDb
+      MaxMindGeoIP2
+      MonoNat
+      NewtonsoftJson
+      NUnit3
+      NUnitConsole
+      OpenNAT
+      RestSharp
+      SharpFont
+      SharpZipLib
+      SmartIrc4net
+      StyleCopMSBuild
+      StyleCopPlusMSBuild
+    ] ++ [
+      lua
+      libGL
+      openal
+      SDL2
+    ];
+
+    # TODO: Test if this is correct.
+    nativeBuildInputs = [
+      curl
+      unzip
+      dos2unix
+      pkgconfig
+      makeWrapper
+      mkdirp
+      mono
+      python
+    ];
+
+    makeFlags = "prefix=$(out)";
+
+    doCheck = true;
+
+    dontStrip = true;
+
+    meta = {
+      maintainers = with maintainers; [ msteen rardiol ];
+      license = licenses.gpl3;
+      platforms = platforms.linux;
+    };
+  };
+}