From 53660e5d1ddda8b8c8b381f884b28a69d6374a63 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 25 Jan 2016 22:19:57 +0100 Subject: humblebundle: Add GuacaMelee This comes with an LD_PRELOAD wrapper that is just used for the initial chdir() where the game tries to set its working directory to the data files. After that all loading of the preload wrapper will fail, but that's okay because we just need to set the data directory and be done with it. We also introduce a callPackage_i686 which is equivalent to the one in but also adds our own packages to the set. Signed-off-by: aszlig --- humblebundle/default.nix | 2 ++ humblebundle/guacamelee.nix | 61 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 humblebundle/guacamelee.nix diff --git a/humblebundle/default.nix b/humblebundle/default.nix index 953f3481..8be6fa16 100644 --- a/humblebundle/default.nix +++ b/humblebundle/default.nix @@ -5,6 +5,7 @@ let self = rec { callPackage = pkgs.lib.callPackageWith (pkgs // self); + callPackage_i686 = pkgs.lib.callPackageWith (pkgs.pkgsi686Linux // self); fetchHumbleBundle = callPackage ./fetch-humble-bundle { inherit (config.humblebundle) email password; @@ -14,6 +15,7 @@ let cavestoryplus = callPackage ./cavestoryplus.nix {}; fez = callPackage ./fez.nix {}; ftl = callPackage ./ftl.nix {}; + guacamelee = callPackage_i686 ./guacamelee.nix {}; hammerwatch = callPackage ./hammerwatch.nix {}; jamestown = callPackage ./jamestown.nix {}; megabytepunch = callPackage ./megabytepunch.nix {}; diff --git a/humblebundle/guacamelee.nix b/humblebundle/guacamelee.nix new file mode 100644 index 00000000..537ec945 --- /dev/null +++ b/humblebundle/guacamelee.nix @@ -0,0 +1,61 @@ +{ stdenv, fetchHumbleBundle, unzip, SDL2, mesa, writeText, makeWrapper }: + +stdenv.mkDerivation rec { + name = "guacamelee-${version}"; + version = "1393037377"; + + src = fetchHumbleBundle { + machineName = "guacamelee_goldedition_linux"; + suffix = "sh"; + md5 = "b06af932c1aaefb8f157c977061388ef"; + }; + + unpackCmd = '' + ${unzip}/bin/unzip "$src" 'data/*' || : + ''; + + preloader = writeText "guacamelee-preloader.c" '' + #define _GNU_SOURCE + #include + + int chdir(const char *path) { + int (*_chdir) (const char *) = dlsym(RTLD_NEXT, "chdir"); + return _chdir(DATA); + } + ''; + + buildInputs = [ makeWrapper ]; + + buildPhase = let + rpath = stdenv.lib.makeLibraryPath [ SDL2 stdenv.cc.cc mesa ]; + fmodRpath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc ]; + in '' + gcc -Werror -shared "$preloader" -o preloader.so -ldl \ + -DDATA=\"$out/share/guacamelee\" + + for i in libfmodevent-4.44.27.so libfmodex-4.44.27.so; do + patchelf --set-rpath "${fmodRpath}:$out/libexec/guacamelee" \ + "x86/lib32/$i" + done + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${rpath}:$out/libexec/guacamelee" x86/game-bin + ''; + + installPhase = '' + install -vD x86/game-bin "$out/libexec/guacamelee/guacamelee" + install -vD preloader.so "$out/libexec/guacamelee/preloader.so" + + makeWrapper "$out/libexec/guacamelee/guacamelee" "$out/bin/guacamelee" \ + --set LD_PRELOAD "$out/libexec/guacamelee/preloader.so" + + for i in libfmodevent-4.44.27.so libfmodex-4.44.27.so; do + install -vD "x86/lib32/$i" "$out/libexec/guacamelee/$i" + done + + mkdir -p "$out/share" + cp -vRd noarch "$out/share/guacamelee" + ''; + + dontStrip = true; +} -- cgit 1.4.1