Skip to content

Commit

Permalink
spacechem: init
Browse files Browse the repository at this point in the history
  • Loading branch information
layus committed Sep 29, 2019
1 parent 93f5d25 commit 602cb4f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkgs/games/humblebundle/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let
owlboy = callPackage ./owlboy.nix {};
pico-8 = callPackage ./pico-8.nix {};
rocketbirds = callPackage ./rocketbirds.nix {};
spacechem = callPackage ./spacechem.nix {};
spaz = callPackage ./spaz.nix {};
starbound = callPackage ./starbound.nix {};
swordsandsoldiers = callPackage ./swordsandsoldiers.nix {};
Expand Down
69 changes: 69 additions & 0 deletions pkgs/games/humblebundle/spacechem.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{ stdenv, lib, fetchHumbleBundle, buildGame
, SDL, SDL_mixer, SDL_image, SDL_net, SDL_gfx, SDL_ttf, smpeg
, mono4, sqlite, coreutils, makeWrapper}:

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";
};

buildInputs = [ 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 dll="${dll}\.dll">/,/<\/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
<configuration>
<dllmap dll="sqlite3" target="${sqlite.out}/lib/libsqlite3.so" os="linux"/>
</configuration>
EOF
cat > SpaceChem/SpaceChem.exe.config <<EOF
<configuration>
<startup><supportedRuntime version="v4.0"/></startup></configuration>
<dllmap dll="sqlite3" target="${sqlite.out}/lib/libsqlite3.so" os="linux"/>
</configuration>
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
postInstall = ''
makeWrapper ${mono4}/bin/mono $out/bin/spacechem \
--prefix PATH : ${coreutils}/bin \
--run "cd $out/lib/SpaceChem" \
--add-flags $out/lib/SpaceChem/SpaceChem.exe
'';
}

0 comments on commit 602cb4f

Please sign in to comment.