diff options
author | aszlig <aszlig@redmoonstudios.org> | 2016-02-08 22:06:10 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2016-02-08 22:06:10 +0100 |
commit | 5570ec94ffe086f1ff47ad99606d39eb7b815dd1 (patch) | |
tree | 71cb764b02d41b1438642b226a3e2840e01caaa6 | |
parent | dbac077ce8ec5a1cc2ddbc8faf335966255a9504 (diff) | |
parent | eba220a4dcce16d02921b27419f039743f1c088f (diff) |
Merge pull request aszlig/nixgames#1 from @layus
This adds Unepic to the humblebundle games list and also fixes Bastion, or at least it *should* fix Bastion. I have tested Unepic, though I had to fix the download, which I'm going to commit later. As for Bastion, at least with the humblebundle fetcher it's not able to fetch "bastion_linux" (it doesn't even show up), however on my Humble library I can see the download (maybe it's because I bought this along with HIB 5). Nevertheless, it's at least a small step forward and we need to fix these issues later.
-rw-r--r-- | humblebundle/bastion.nix | 59 | ||||
-rw-r--r-- | humblebundle/default.nix | 1 | ||||
-rw-r--r-- | humblebundle/fetch-humble-bundle/default.nix | 4 | ||||
-rw-r--r-- | humblebundle/unepic.nix | 44 |
4 files changed, 95 insertions, 13 deletions
diff --git a/humblebundle/bastion.nix b/humblebundle/bastion.nix index 652b8011..b4acda6b 100644 --- a/humblebundle/bastion.nix +++ b/humblebundle/bastion.nix @@ -1,25 +1,62 @@ -{ stdenv, fetchHumbleBundle, lzma, mono }: +{ stdenv, fetchHumbleBundle, lzma, xorg, libpulseaudio}: let - arch = if stdenv.system == "i686-linux" then "x86" - else if stdenv.system == "x86_64-linux" then "x86_64" - else throw "Unsupported architecture ${stdenv.system}!"; + arch = { + "i686-linux" = "x86"; + "x86_64-linux" = "x86_64"; + }.${stdenv.system}; in stdenv.mkDerivation rec { name = "bastion-1.4"; src = fetchHumbleBundle { name = "Bastion-HIB-2012-06-20.sh"; + machineName = "bastion_linux"; + downloadName = ".sh"; md5 = "aa6ccaead3b4b8a5fbd156f4019e8c8b"; }; - unpackCmd = '' - mkdir "${name}" + dontStrip = true; + phases = ["installPhase"]; - sh "$src" --tar xf ./instarchive_all -O | ${lzma}/bin/lzcat \ - | tar x -C "${name}" Bastion.exe - ''; + installPhase = let + rpath = stdenv.lib.makeLibraryPath [ + "$dest" + xorg.libX11 + xorg.libXi + stdenv.cc.cc + libpulseaudio + ]; + in '' + dest="$out/opt/games/bastion" + libdir="$dest/lib" #${stdenv.lib.optionalString (arch=="x86_64") "64"}" + + # Unpack binaries and data into $dest + mkdir -p "$dest" + sh "$src" --tar xf ./instarchive_all -O | ${lzma}/bin/lzcat | tar x -C "$dest" + sh "$src" --tar xf ./instarchive_linux_${arch} -O | ${lzma}/bin/lzcat | tar x -C "$dest" + + # Ensure that $dest is a valid library path. + mv $dest/lib64 $libdir || true + + # Patch heavily :-) + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${rpath}" "$dest/Bastion.bin.${arch}" + patchelf --set-rpath "${rpath}" "$libdir/libmono-2.0.so.1" + patchelf --set-rpath "${rpath}" "$libdir/libfmodex.so" + patchelf --set-rpath "${rpath}" "$libdir/libSDL-1.2.so.0" + + # Fixup permissions, just to be sure. + find "$dest" -type f -exec chmod 644 "{}" + + chmod 755 "$dest/Bastion.bin.${arch}" + + # Taken from ArchLinux; might be useful to actually implement + #install -Dm644 "''${pkgname}".desktop "''${pkgdir}"/usr/share/applications/"''${pkgname}".desktop + #install -Dm755 "mesa''${pkgname}" "''${pkgdir}"/usr/bin/"''${pkgname}"mesa + #install -Dm644 "''${pkgdir}"/opt/games/Bastion/Bastion.png "''${pkgdir}"/usr/share/icons/"''${pkgname}".png - installPhase = '' - install -vD "Bastion.bin.${arch}" "$out/bin/bastion" + # XXX: Make wrapper instead of symlink ? See ArchLinux's bastionmesa above. + mkdir -p "$out/bin" + ln -s "$dest/Bastion.bin.${arch}" "$out/bin/bastion" ''; } diff --git a/humblebundle/default.nix b/humblebundle/default.nix index 6c2ea937..237a5dc6 100644 --- a/humblebundle/default.nix +++ b/humblebundle/default.nix @@ -23,6 +23,7 @@ let rocketbirds = callPackage ./rocketbirds.nix {}; spaz = callPackage ./spaz.nix {}; swordsandsoldiers = callPackage ./swordsandsoldiers.nix {}; + unepic = callPackage ./unepic.nix {}; }; in with lib; { options.humblebundle = { diff --git a/humblebundle/fetch-humble-bundle/default.nix b/humblebundle/fetch-humble-bundle/default.nix index c37e2043..fbabaa8c 100644 --- a/humblebundle/fetch-humble-bundle/default.nix +++ b/humblebundle/fetch-humble-bundle/default.nix @@ -4,7 +4,7 @@ , email, password }: -{ machineName, downloadName ? "Download", suffix ? "humblebundle", md5 }: let +{ name ? null, machineName, downloadName ? "Download", suffix ? "humblebundle", md5 }: let cafile = "${cacert}/etc/ssl/certs/ca-bundle.crt"; humbleAPI = buildPythonPackage rec { @@ -72,7 +72,7 @@ print dstruct.url.web ''; in stdenv.mkDerivation { - name = "${machineName}.${suffix}"; + name = if name != null then name else "${machineName}.${suffix}"; outputHashAlgo = "md5"; outputHash = md5; diff --git a/humblebundle/unepic.nix b/humblebundle/unepic.nix new file mode 100644 index 00000000..cc4099f5 --- /dev/null +++ b/humblebundle/unepic.nix @@ -0,0 +1,44 @@ +{ stdenv, fetchHumbleBundle, unzip, makeWrapper, SDL2, SDL2_mixer, zlib }: + +let + version = "1.50.5"; + versionName = "15005"; + arch = { + "i686-linux" = "32"; + "x86_64-linux" = "64"; + }.${stdenv.system}; +in stdenv.mkDerivation rec { + name = "unepic-${version}"; + + src = fetchHumbleBundle { + name = "unepic-15005.run"; + machineName = "unepic_linux"; + downloadName = ".run"; + md5 = "940824c4de6e48522845f63423e87783"; + }; + + phases = [ "installPhase" ]; + + buildInputs = [ unzip makeWrapper ]; + + installPhase = let + rpath = stdenv.lib.makeLibraryPath [ SDL2 SDL2_mixer zlib stdenv.cc.cc ]; + in '' + dest="$out/opt/games/unepic" + exe="$dest/unepic${arch}" + + mkdir -p "$out/opt/games" + unzip "$src" "data/*" -d "$out/opt/games" || [ "$?" -eq 1 ] + mv "$out/opt/games/data" "$dest" + rm -r "$dest"/lib* + + # Patch $exe acccording to arch. + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${rpath}" "$exe" + + mkdir -p "$out/bin" + + makeWrapper "$exe" "$out/bin/unepic" --run "cd '$dest'" + ''; +} |