about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-06-28 03:31:48 +0200
committeraszlig <aszlig@nix.build>2018-06-28 03:42:05 +0200
commit387049370eb5e61e0629d2dd80975dba1a304a58 (patch)
tree45210bc12fb3dbb7e2bdaf9e8d81b0bc3c9e08cf /pkgs/games
parent4d55db84945f05cf9bff86354946dc70bb1af794 (diff)
games/gog: Add Thimbleweed Park
This also supports the "Ransome Unbeeped" addon which should get rid of
all the beeps from Ransome's voice tracks. I added this by default in
the package, because in order to enable it you still either need to
enable it every time you start the game or set "forceRansomeUnbeeped: 1"
in "$XDG_DATA_HOME/Terrible Toybox/Thimbleweed Park/Prefs.json" to make
it permanent.

The packaging is pretty straightforward except a small preloader which
changes the working directory to the shared data directory so the
"ggpack" files can be found. From inspecting the binary this should also
be doable by setting the THIMBLEENGINE_GAMEROOT environment variable,
but I haven't tried yet.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/gog/default.nix1
-rw-r--r--pkgs/games/gog/thimbleweed-park.nix55
2 files changed, 56 insertions, 0 deletions
diff --git a/pkgs/games/gog/default.nix b/pkgs/games/gog/default.nix
index 73152880..7ed321f1 100644
--- a/pkgs/games/gog/default.nix
+++ b/pkgs/games/gog/default.nix
@@ -19,6 +19,7 @@ let
     stardew-valley-beta = lib.lowPrio (callPackage ./stardew-valley.nix {
       beta = true;
     });
+    thimbleweed-park = callPackage ./thimbleweed-park.nix {};
     wizard-of-legend = callPackage ./wizard-of-legend.nix {};
     xeen = callPackage ./xeen.nix {};
   };
diff --git a/pkgs/games/gog/thimbleweed-park.nix b/pkgs/games/gog/thimbleweed-park.nix
new file mode 100644
index 00000000..a37074cc
--- /dev/null
+++ b/pkgs/games/gog/thimbleweed-park.nix
@@ -0,0 +1,55 @@
+{ lib, buildGame, fetchGog, unzip, libGL, libudev
+
+, ransomeUnbeeped ? true
+}:
+
+buildGame rec {
+  name = "thimbleweed-park-${version}";
+  version = "1.0.958";
+
+  srcs = lib.singleton (fetchGog {
+    productId = 1325604411;
+    downloadName = "en3installer0";
+    sha256 = "141263g749k9h4741q8dyv7149n20zx50rhl0ny8ly6p4yw1spv7";
+  }) ++ lib.optional ransomeUnbeeped (fetchGog {
+    productId = 1858019230;
+    downloadName = "en3installer0";
+    sha256 = "1cfll73qazm9nz40n963qvankqkznfjai9g88kgw6xcl40y8jrqn";
+  });
+
+  unpackCmd = "${unzip}/bin/unzip -qq \"$curSrc\" 'data/noarch/game/*' || :";
+
+  buildInputs = [ libGL ];
+
+  runtimeDependencies = [ libudev ];
+
+  # A small preload wrapper which changes into the data directory during
+  # startup of the main binary.
+  buildPhase = ''
+    cc -Werror -Wall -std=c11 -shared -xc - -o preload.so -fPIC <<EOF
+    #include <stdio.h>
+    #include <unistd.h>
+
+    __attribute__((constructor)) static void chdirToData(void) {
+      if (chdir("$out/share/thimbleweed-park") == -1) {
+        perror("chdir $out/share/thimbleweed-park");
+        _exit(1);
+      }
+    }
+    EOF
+    patchelf --add-needed "$out/libexec/thimbleweed-park/preload.so" \
+      ThimbleweedPark
+  '';
+
+  installPhase = ''
+    install -vD ThimbleweedPark "$out/bin/thimbleweed-park"
+    install -vD preload.so "$out/libexec/thimbleweed-park/preload.so"
+    for i in *.ggpack[0-9]*; do
+      install -vD -m 0644 "$i" "$out/share/thimbleweed-park/$i"
+    done
+  '';
+
+  sandbox.paths.required = [
+    "$XDG_DATA_HOME/Terrible Toybox/Thimbleweed Park"
+  ];
+}