Skip to content

Commit

Permalink
spacechem: init
Browse files Browse the repository at this point in the history
  • Loading branch information
layus committed Aug 6, 2018
1 parent a8e4069 commit 65bf63f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkgs/games/build-support/build-game.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ assert withPulseAudio -> libpulseaudio != null;
{ buildInputs ? []
, nativeBuildInputs ? []
, preUnpack ? ""
, setSourceRoot ? ""
, runtimeDependencies ? []
, sandbox ? {}
, ...
Expand All @@ -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)"
Expand Down
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
62 changes: 62 additions & 0 deletions pkgs/games/humblebundle/spacechem.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{ stdenv, lib, fetchHumbleBundle, buildGame
, SDL, SDL_mixer, SDL_image, SDL_net, SDL_gfx, SDL_ttf, smpeg
, mono, sqlite, coreutils }:

with lib;

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

# 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)
'';

postFixup = 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}"'"!
}' Tao.Sdl.dll.config
'') dllmap)}
rm Mono.Security.dll
cat > System.Data.SQLite.dll.config <<EOF
<configuration>
<dllmap dll="sqlite3" target="${sqlite.out}/lib/libsqlite3.so" os="linux"/>
</configuration>
EOF
'';

# coreutils because Tao.OpenGL relies on uname for platform detection
installPhase = ''
mkdir -p $out/bin
cat > $out/bin/spacechem <<EOF
#!${stdenv.shell}
cd $out/lib/spacechem
PATH=${coreutils}/bin:$PATH
exec ${mono}/bin/mono SpaceChem.exe "$@"
EOF
chmod +x $out/bin/spacechem
'';
}

0 comments on commit 65bf63f

Please sign in to comment.