From 5d98818c8e2e7cdf2bfe0dbd0c2a8fd069e9acb9 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sat, 9 Jun 2018 05:22:56 +0200 Subject: games/gog: Add World of Xeen This is the result when you combine Might and Magic 4 and 5 and ScummVM very recently got support for that. See http://scummvm.org/news/20180501 for the announcement. So we're wrapping the game using latest git version of ScummVM. Signed-off-by: aszlig --- pkgs/games/gog/default.nix | 1 + pkgs/games/gog/xeen.nix | 123 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 pkgs/games/gog/xeen.nix (limited to 'pkgs/games/gog') diff --git a/pkgs/games/gog/default.nix b/pkgs/games/gog/default.nix index 3e86c8a0..2379cd26 100644 --- a/pkgs/games/gog/default.nix +++ b/pkgs/games/gog/default.nix @@ -16,6 +16,7 @@ let stardew-valley-beta = lib.lowPrio (callPackage ./stardew-valley.nix { beta = true; }); + xeen = callPackage ./xeen.nix {}; }; in { options.gog = { diff --git a/pkgs/games/gog/xeen.nix b/pkgs/games/gog/xeen.nix new file mode 100644 index 00000000..93a7beb8 --- /dev/null +++ b/pkgs/games/gog/xeen.nix @@ -0,0 +1,123 @@ +{ lib, stdenv, buildSandbox, fetchGog, innoextract, bchunk, p7zip +, scummvm, fetchFromGitHub +, runCommand, xvfb_run + +, showItemCosts ? true +, durableArmor ? true +}: + +let + version = "2.1.0.43"; + + gameData = stdenv.mkDerivation { + name = "world-of-xeen-gamedata-${version}"; + inherit version; + + src = fetchGog { + name = "setup_mm45_${version}.exe"; + productId = 1207661233; + downloadName = "en1installer1"; + sha256 = "0jv9k5rcapqlk61pawa5l4m34iwllx8j6cfz69gl092h04fvfqki"; + }; + + unpackCmd = toString [ + "${innoextract}/bin/innoextract" + "--include" "app/game1.gog" + "--include" "app/music" + "-L" "-m" "\"$curSrc\"" + ]; + + patchPhase = '' + cat > game1.inst <&2 + ls -l "$out" + exit 1 + fi + trackFileNo="$(ls -1 "$out/"track[0-9][0-9].ogg | wc -l)" + if [ "$trackFileNo" -ne 59 ]; then + echo "Expected 59 track[0-9][0-9].ogg files, but got $trackFileNo." >&2 + ls -l "$out" + exit 1 + fi + ''; + }; + + latestScummVM = scummvm.overrideAttrs (drv: { + src = fetchFromGitHub { + owner = "scummvm"; + repo = "scummvm"; + rev = "7edac197e4aa9846b71f398d9c5a4d56c5b7c34e"; + sha256 = "0vj0widczlmvbnv6qzfsh14mhil3p2rbfpj86fb4syrbb8qrc01g"; + }; + + configureFlags = (drv.configureFlags or []) ++ [ + "--disable-all-engines" "--enable-engine=xeen" + ]; + + # Current Git version has an --enable-static option so the stdenv setup + # thinks that there is --disable-static as well, which is not. + dontDisableStatic = true; + }); + + injectOption = c: o: lib.optionalString c "-e '/^\\[worldof/a ${o}=true'"; + + scummVmConfig = runCommand "scummvm-xeen.ini" { + nativeBuildInputs = [ xvfb_run latestScummVM ]; + inherit gameData; + } '' + xvfb-run scummvm -p "$gameData" -a + sed -e '/^\[scummvm\]/a enable_unsupported_game_warning=false' \ + ${injectOption showItemCosts "ShowItemCosts"} \ + ${injectOption durableArmor "DurableArmor"} \ + scummvm.ini > "$out" + ''; + + unsandboxed = runCommand "word-of-xeen-${version}" { + scummVmCmd = "${latestScummVM}/bin/scummvm"; + dataHome = "\"\${XDG_DATA_HOME:-$HOME/.local/share}/xeen\""; + inherit (stdenv) shell; + scummVmArgs = lib.concatMapStringsSep " " lib.escapeShellArg [ + "-c" scummVmConfig + ]; + } '' + mkdir -p "$out/bin" + cat > "$out/bin/xeen" <