about summary refs log tree commit diff
path: root/pkgs/games/gog/stardew-valley.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-02-22 05:11:30 +0100
committeraszlig <aszlig@nix.build>2018-02-22 05:11:30 +0100
commited298980c48f3c71ec15b91fe7779d8e89639f2a (patch)
tree2fe83982ef3ced56115efcaa83fca0e039421616 /pkgs/games/gog/stardew-valley.nix
parent5136f67286519753b9696b4ac46a0e7afd0efe43 (diff)
pkgs/games/gog: Add Stardew Valley
This is quite straightforward and very similar to most other Mono games
and even uses XDG directories already.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games/gog/stardew-valley.nix')
-rw-r--r--pkgs/games/gog/stardew-valley.nix46
1 files changed, 46 insertions, 0 deletions
diff --git a/pkgs/games/gog/stardew-valley.nix b/pkgs/games/gog/stardew-valley.nix
new file mode 100644
index 00000000..ee39fbd9
--- /dev/null
+++ b/pkgs/games/gog/stardew-valley.nix
@@ -0,0 +1,46 @@
+{ lib, buildGame, fetchGog, unzip, makeWrapper, mono50, SDL2, openal }:
+
+buildGame rec {
+  name = "stardew-valley-${version}";
+  version = "1.2.33";
+
+  src = fetchGog {
+    productId = 1453375253;
+    downloadName = "en3installer10";
+    sha256 = "199xf008cxm6ywb4d8c3dz0h7iiv9d0ka5k93gq0jqj3ga3fjn3i";
+  };
+
+  unpackCmd = "${unzip}/bin/unzip -qq \"$curSrc\" 'data/noarch/game/*' || :";
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  buildPhase = let
+    dllmap = {
+      SDL2 = "${SDL2}/lib/libSDL2.so";
+      soft_oal = "${openal}/lib/libopenal.so";
+    };
+  in lib.concatStrings (lib.mapAttrsToList (dll: target: ''
+    sed -i -e '/<dllmap.*dll="${dll}\.dll".*os="linux"/ {
+      s!target="[^"]*"!target="'"${target}"'"!
+    }' MonoGame.Framework.dll.config
+  '') dllmap);
+
+  installPhase = ''
+    mkdir -p "$out/share" "$out/libexec/stardew-valley"
+
+    cp -rv Content "$out/share/stardew-valley"
+    cp -rv monoconfig "$out/libexec/stardew-valley/StardewValley.exe.config"
+    cp -rvt "$out/libexec/stardew-valley" StardewValley.exe \
+      MonoGame.Framework.dll* BmFont.dll xTile.dll Lidgren.Network.dll
+    ln -s "$out/share/stardew-valley" "$out/libexec/stardew-valley/Content"
+
+    makeWrapper ${lib.escapeShellArg mono50}/bin/mono \
+      "$out/bin/stardew-valley" \
+      --add-flags "$out/libexec/stardew-valley/StardewValley.exe" \
+      --run "cd '$out/libexec/stardew-valley'"
+  '';
+
+  sandbox.paths.required = [
+    "$XDG_DATA_HOME/StardewValley" "$XDG_CONFIG_HOME/StardewValley"
+  ];
+}