diff --git a/pkgs/games/humblebundle/default.nix b/pkgs/games/humblebundle/default.nix index 5de3f40e..d32144c7 100644 --- a/pkgs/games/humblebundle/default.nix +++ b/pkgs/games/humblebundle/default.nix @@ -30,6 +30,7 @@ let owlboy = callPackage ./owlboy.nix {}; pico-8 = callPackage ./pico-8.nix {}; rocketbirds = callPackage ./rocketbirds.nix {}; + spacechem = callPackage_i686 ./spacechem.nix {}; spaz = callPackage ./spaz.nix {}; starbound = callPackage ./starbound.nix {}; swordsandsoldiers = callPackage ./swordsandsoldiers.nix {}; diff --git a/pkgs/games/humblebundle/spacechem.nix b/pkgs/games/humblebundle/spacechem.nix new file mode 100644 index 00000000..6181e1c0 --- /dev/null +++ b/pkgs/games/humblebundle/spacechem.nix @@ -0,0 +1,76 @@ +{ buildGame, fetchHumbleBundle, lib + +, SDL, SDL_gfx, SDL_image, SDL_mixer, SDL_net, SDL_ttf +, coreutils, makeWrapper, mono4, smpeg, sqlite, xclip +}: + +with lib; + +buildGame rec { + version = "1013_FIXED"; + name = "spacechem-${version}"; + src = fetchHumbleBundle { + name = "SpaceChem_Linux_v1013_FIXED.zip"; + machineName = "spacechem_android_pc_soundtrack_linux"; + downloadName = "Download"; + md5 = "c290e8631ae3380b7e70362501a5adb6"; + }; + + sandbox.paths.required = [ + "$XDG_DATA_HOME/Zachtronics Industries/SpaceChem" + ]; + + nativeBuildInputs = [ makeWrapper ]; + + postPatch = let + dllmap = { + SDL = "${SDL}/lib/libSDL.so"; + SDL_image = "${SDL_image}/lib/libSDL_image.so"; + SDL_mixer = "${SDL_mixer}/lib/libSDL_mixer.so"; + SDL_ttf = "${SDL_ttf}/lib/libSDL_ttf.so"; + SDL_net = "${SDL_net}/lib/libSDL_net.so"; + smpeg = "${smpeg}/lib/libsmpeg.so"; + SDL_gfx = "${SDL_gfx}/lib/libSDL_gfx.so"; + }; + in '' + ${concatStrings (mapAttrsToList (dll: target: '' + sed -i -e '//,/<\/dllmap>/ { + /dllentry os="linux"/s!dll="[^"]*"!dll="'"${target}"'"! + }' SpaceChem/Tao.Sdl.dll.config + '') dllmap)} + + rm SpaceChem/Mono.Security.dll + rm SpaceChem/spacechem-launcher.sh + + cat > SpaceChem/System.Data.SQLite.dll.config < + + + EOF + cat > SpaceChem/SpaceChem.exe.config < + + + + EOF + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib + cp -rvt $out/lib SpaceChem + + runHook postInstall + ''; + + # coreutils because Tao.OpenGL relies on uname for platform detection + # xclip because SpaceChem relies on it for import/export of challenges + postInstall = '' + makeWrapper ${mono4}/bin/mono $out/bin/spacechem \ + --prefix PATH : ${coreutils}/bin \ + --prefix PATH : ${xclip}/bin \ + --run "cd $out/lib/SpaceChem" \ + --add-flags $out/lib/SpaceChem/SpaceChem.exe + ''; +}