about summary refs log tree commit diff
path: root/humblebundle
diff options
context:
space:
mode:
Diffstat (limited to 'humblebundle')
-rw-r--r--humblebundle/default.nix3
-rw-r--r--humblebundle/fetch-humble-bundle/default.nix17
-rw-r--r--humblebundle/guacamelee.nix61
-rw-r--r--humblebundle/liads.nix43
4 files changed, 117 insertions, 7 deletions
diff --git a/humblebundle/default.nix b/humblebundle/default.nix
index e77a7deb..237a5dc6 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,8 +15,10 @@ 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 {};
+    liads = callPackage ./liads.nix {};
     megabytepunch = callPackage ./megabytepunch.nix {};
     rocketbirds = callPackage ./rocketbirds.nix {};
     spaz = callPackage ./spaz.nix {};
diff --git a/humblebundle/fetch-humble-bundle/default.nix b/humblebundle/fetch-humble-bundle/default.nix
index 3e0bc5ad..fbabaa8c 100644
--- a/humblebundle/fetch-humble-bundle/default.nix
+++ b/humblebundle/fetch-humble-bundle/default.nix
@@ -21,6 +21,8 @@
     propagatedBuildInputs = with pythonPackages; [ requests2 ];
   };
 
+  pyStr = str: "'${stdenv.lib.escape ["'" "\\"] str}'";
+
   getDownloadURL = writeText "gethburl.py" ''
     import sys, humblebundle
 
@@ -38,32 +40,33 @@
 
     def find_download(downloads):
       for machine_name, dstruct in sum(downloads.values(), []):
-        if machine_name == '${machineName}':
+        if machine_name == ${pyStr machineName}:
           for ds in dstruct:
-            if ds.name == '${downloadName}':
+            if ds.name == ${pyStr downloadName}:
               return ds
           print >>sys.stderr, \
-            'Unable to find ${downloadName} for ${machineName}!'
+            ${pyStr "Unable to find ${downloadName} for ${machineName}!"}
           print >>sys.stderr, 'Available download types:'
           for ds in dstruct:
             print >>sys.stderr, "  " + ds.name
           raise SystemExit(1)
 
     hb = humblebundle.HumbleApi()
-    hb.login('${email}', '${password}')
+    hb.login(${pyStr email}, ${pyStr password})
     products = dict(get_products(hb))
     dstruct = find_download(products)
 
     if dstruct is None:
-      print >>sys.stderr, 'Cannot find download for ${machineName}!'
+      print >>sys.stderr, ${pyStr "Cannot find download for ${machineName}!"}
       print >>sys.stderr, 'Available machine names:'
       for name, dstructs in sorted(products.items(), key=lambda x: x[0]):
         print >>sys.stderr, "  * " + name
         print >>sys.stderr, "    " + ', '.join(map(lambda x: x[0], dstructs))
       raise SystemExit(1)
-    elif dstruct.md5 != '${md5}':
+    elif dstruct.md5 != ${pyStr md5}:
       print >>sys.stderr, \
-        'MD5 for ${machineName} is not ${md5} but ' + dstruct.md5 + '.'
+        ${pyStr "MD5 for ${machineName} is not ${md5} but "} \
+        + dstruct.md5 + '.'
       raise SystemExit(1)
     else:
       print dstruct.url.web
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 <dlfcn.h>
+
+    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;
+}
diff --git a/humblebundle/liads.nix b/humblebundle/liads.nix
new file mode 100644
index 00000000..a96af8e0
--- /dev/null
+++ b/humblebundle/liads.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchHumbleBundle, unzip, mesa, xorg, libpulseaudio }:
+
+stdenv.mkDerivation rec {
+  name = "liads-${version}";
+  version = "20160121";
+
+  src = fetchHumbleBundle {
+    machineName = "loversinadangerousspacetime_linux";
+    suffix = "zip";
+    md5 = "0d81adb63ca9233165fb5de415fa5963";
+  };
+
+  unpackCmd = ''
+    ${unzip}/bin/unzip -qq -d liads "$src" || :
+  '';
+
+  arch = if stdenv.system == "x86_64-linux" then "x86_64" else "x86";
+  executable = "LoversInADangerousSpacetime.${arch}";
+
+  buildPhase = let
+    rpath = stdenv.lib.makeLibraryPath [
+      stdenv.cc.cc mesa xorg.libX11 xorg.libXcursor xorg.libXrandr libpulseaudio
+    ];
+  in ''
+    patchelf \
+      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+      --set-rpath "${rpath}" "$executable"
+  '';
+
+  installPhase = ''
+    install -vD "$executable" "$out/libexec/liads/liads"
+    ln -s "$out/share/liads" "$out/libexec/liads/Data"
+
+    mkdir -p "$out/bin"
+    ln -s "$out/libexec/liads/liads" "$out/bin/liads"
+
+    mkdir -p "$out/share"
+    cp -vRd LoversInADangerousSpacetime_Data "$out/share/liads"
+  '';
+
+  dontStrip = true;
+  dontPatchELF = true;
+}