From 4c919e68d71669a09b45d67a18b8ebb5baa21d45 Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 11 Jun 2019 07:21:03 +0200 Subject: games/gog: Add The Longest Journey This is basically a wrapper around ResidualVM, which I also patched so that we can inject a basic config file from the Nix store that contains the basic game information. The ResidualVM build is pretty minimal in that we only use those dependencies that we actually need for the game. Signed-off-by: aszlig Cc: @Profpatsch --- pkgs/games/gog/default.nix | 1 + pkgs/games/gog/the-longest-journey/default.nix | 106 +++++++++++++++++++++ .../the-longest-journey/predefined-config.patch | 29 ++++++ 3 files changed, 136 insertions(+) create mode 100644 pkgs/games/gog/the-longest-journey/default.nix create mode 100644 pkgs/games/gog/the-longest-journey/predefined-config.patch (limited to 'pkgs/games/gog') diff --git a/pkgs/games/gog/default.nix b/pkgs/games/gog/default.nix index 122a8365..479dbc27 100644 --- a/pkgs/games/gog/default.nix +++ b/pkgs/games/gog/default.nix @@ -21,6 +21,7 @@ let satellite-reign = callPackage ./satellite-reign.nix {}; settlers2 = callPackage ./settlers2.nix {}; stardew-valley = callPackage ./stardew-valley.nix {}; + the-longest-journey = callPackage ./the-longest-journey {}; thimbleweed-park = callPackage ./thimbleweed-park.nix {}; war-for-the-overworld = callPackage ./war-for-the-overworld.nix {}; wizard-of-legend = callPackage ./wizard-of-legend.nix {}; diff --git a/pkgs/games/gog/the-longest-journey/default.nix b/pkgs/games/gog/the-longest-journey/default.nix new file mode 100644 index 00000000..9dca199a --- /dev/null +++ b/pkgs/games/gog/the-longest-journey/default.nix @@ -0,0 +1,106 @@ +{ stdenv, lib, fetchGog, fetchFromGitHub, innoextract, runCommand, buildSandbox +, SDL2, SDL2_net, freetype, libGLU_combined, glew, alsaLib +, libogg, libvorbis, xvfb_run +}: + +let + gameData = runCommand "the-longest-journey-data" rec { + version = "142"; + + # We need a newer version that 1.7, because GOG uses a newer archive + # format. + nativeBuildInputs = lib.singleton (innoextract.overrideAttrs (drv: { + src = fetchFromGitHub { + owner = "dscharrer"; + repo = "innoextract"; + rev = "4c61bc4da822fc89f2e05bdb2c45e6c4dd7a3673"; + sha256 = "197pr7dzlza4isssvhqhvnrr7wzc9c4b3wnnp03sxpmhviyidln1"; + }; + })); + + data = fetchGog { + name = "the-longest-journey-${version}.bin"; + productId = 1207658794; + downloadName = "en1installer1"; + sha256 = "08jg5snlxkzxppq37lsmbhgv9zhwnk1zr4cid5gynzq9b1048rzc"; + }; + + setup = fetchGog { + name = "the-longest-journey-${version}.exe"; + productId = 1207658794; + downloadName = "en1installer0"; + sha256 = "1h4c2bhf5mhz004r37dwdydl3rhpg1wyr4kyvxxwma7x9grxqyzc"; + }; + } '' + ln -s "$data" archive-1.bin + ln -s "$setup" archive.exe + innoextract -L -m archive.exe + mkdir "$out" + mv -t "$out" \ + game.exe gui.ini chapters.ini language.ini x.xarc \ + static global fonts [a-f0-9][a-f0-9] + ''; + + residualvm = stdenv.mkDerivation rec { + name = "residualvm-${version}"; + version = "20190611"; + + src = fetchFromGitHub { + owner = "residualvm"; + repo = "residualvm"; + rev = "ae1a7fbf6fa6bf88a7adebaedb2cd713d5ccc718"; + sha256 = "1521578jis9s3ilz0ws0msanviyqf70dp54db3d6ssfikc0w3myx"; + }; + + patches = [ ./predefined-config.patch ]; + + # Current Git version has an --enable-static option so the stdenv setup + # thinks that there is --disable-static as well, which doesn't exist. + dontDisableStatic = true; + + enableParallelBuilding = true; + buildInputs = [ + SDL2 SDL2_net freetype libGLU_combined glew alsaLib + libogg libvorbis + ]; + + configureFlags = [ "--disable-all-engines" "--enable-engine=stark" ]; + }; + + configFile = runCommand "residualvm-stark.ini" { + nativeBuildInputs = [ xvfb_run residualvm ]; + inherit gameData; + } '' + xvfb-run residualvm -p "$gameData" -a + sed -e '/^\[residualvm\]/a enable_unsupported_game_warning=false' \ + residualvm.ini > "$out" + ''; + + unsandboxed = runCommand "the-longest-journey-${gameData.version}" { + residualCmd = "${residualvm}/bin/residualvm"; + configArgs = let + mkXdg = what: fallback: extra: let + basePath = "\${XDG_${what}_HOME:-$HOME/${fallback}}"; + in "\"${basePath}/the-longest-journey${extra}\""; + in [ + "--savepath=${mkXdg "DATA" ".local/share" ""}" + "--config=${mkXdg "CONFIG" ".config" "/settings.ini"}" + ]; + inherit (stdenv) shell; + residualArgs = lib.escapeShellArgs [ "--predefined-config=${configFile}" ]; + } '' + mkdir -p "$out/bin" + cat > "$out/bin/the-longest-journey" <