From 542ac4c93e5f43f81fd63de024f2870b336bd48d Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Thu, 2 Aug 2018 20:51:26 +0200 Subject: [PATCH] fixup! spacechem: init --- pkgs/games/build-support/build-game.nix | 3 +- pkgs/games/humblebundle/spacechem.nix | 50 +++++++++++-------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/pkgs/games/build-support/build-game.nix b/pkgs/games/build-support/build-game.nix index 459fca75..57fbe23c 100644 --- a/pkgs/games/build-support/build-game.nix +++ b/pkgs/games/build-support/build-game.nix @@ -9,7 +9,6 @@ assert withPulseAudio -> libpulseaudio != null; { buildInputs ? [] , nativeBuildInputs ? [] , preUnpack ? "" -, setSourceRoot ? "" , runtimeDependencies ? [] , sandbox ? {} , ... @@ -30,7 +29,7 @@ buildSandbox (stdenv.mkDerivation ({ # Try to evade tarbombs setSourceRoot = '' popd &> /dev/null - '' + lib.optionalString (setSourceRoot == "") '' + '' + attrs.setSourceRoot or '' sourceRoot="$(find "$name" -type d -exec sh -c ' ndirs="$(find "$1" -mindepth 1 -maxdepth 1 -type d -printf x | wc -m)" nelse="$(find "$1" -mindepth 1 -maxdepth 1 ! -type d -printf x | wc -m)" diff --git a/pkgs/games/humblebundle/spacechem.nix b/pkgs/games/humblebundle/spacechem.nix index 3561dc3b..f34ecd26 100644 --- a/pkgs/games/humblebundle/spacechem.nix +++ b/pkgs/games/humblebundle/spacechem.nix @@ -1,32 +1,26 @@ -{ stdenv, fetchHumbleBundle, unzip, makeWrapper, +{ stdenv, fetchHumbleBundle, unzip, buildGame, SDL, SDL_mixer, SDL_image, SDL_net, SDL_gfx, SDL_ttf, -smpeg, zlib, mono, monoDLLFixer, sqlite }: +smpeg, zlib, mono, monoDLLFixer, sqlite, coreutils }: -let - version = "1.0.12-2"; - versionName = "15005"; - arch = { - "i686-linux" = "i686"; - "x86_64-linux" = "x86_64"; - }.${stdenv.system}; -in stdenv.mkDerivation rec { +buildGame rec { + version = "1012-2"; # from deb version name = "spacechem-${version}"; src = fetchHumbleBundle { name = "spacechem-linux-1345144627-amd64.deb"; machineName = "spacechem_android_pc_soundtrack_linux"; downloadName = "amd64.deb"; - #md5 = "2df1aa8d2709c94e7990742210c35940"; md5 = "c08fb05e1909c0b4ccae82a862da6e3a"; }; - phases = [ "installPhase" "fixupPhase" ]; - - buildInputs = [ makeWrapper ]; - - inherit monoDLLFixer; + # strip 4 components (namely ./opt/zatronicsindustries/spacechem -> $sourceRoot) + unpackPhase = '' + sourceRoot=$out/lib/spacechem + mkdir -p $sourceRoot + ar p "$src" data.tar.gz | (cd $sourceRoot; tar xz ./opt --strip-components=4) + ''; - installPhase = let + postFixup = let rpath = stdenv.lib.makeLibraryPath [ SDL SDL_mixer zlib stdenv.cc.cc ]; dllmap = { SDL = "${SDL}/lib/libSDL.so"; @@ -38,32 +32,30 @@ in stdenv.mkDerivation rec { SDL_gfx = "${SDL_gfx}/lib/libSDL_gfx.so"; }; in '' - set -x - mkdir $out - ar p $src data.tar.gz | (cd $out; tar xvzf - ./opt) - mv $out/usr/bin $out/bin && rmdir $out/usr - ${stdenv.lib.concatStrings (stdenv.lib.mapAttrsToList (dll: target: '' sed -i -e '//,/<\/dllmap>/ { /dllentry os="linux"/s!dll="[^"]*"!dll="'"${target}"'"! - }' $out/opt/zachtronicsindustries/spacechem/Tao.Sdl.dll.config + }' Tao.Sdl.dll.config '') dllmap)} - rm $out/opt/zachtronicsindustries/spacechem/Mono.Security.dll + rm Mono.Security.dll - cat > $out/opt/zachtronicsindustries/spacechem/System.Data.SQLite.dll.config < System.Data.SQLite.dll.config < EOF + ''; - mkdir $out/bin + # coreutils because Tao.OpenGL relies on uname for platform detection + installPhase = '' + mkdir -p $out/bin cat > $out/bin/spacechem <