@@ -1,5 +1,5 @@
11{ fetchFromGitHub, stdenv, makeWrapper, pkgconfig, ncurses, lua, SDL2, SDL2_image, SDL2_ttf,
2−SDL2_mixer, freetype, gettext, Cocoa }:
2+SDL2_mixer, freetype, gettext, Cocoa, libicns }:
33
44stdenv.mkDerivation rec {
55 version = "0.C";
@@ -12,7 +12,8 @@ stdenv.mkDerivation rec {
1212 sha256 = "03sdzsk4qdq99qckq0axbsvg1apn6xizscd8pwp5w6kq2fyj5xkv";
1313 };
1414
15− nativeBuildInputs = [ makeWrapper pkgconfig ];
15+ nativeBuildInputs = [ makeWrapper pkgconfig ]
16+ ++ stdenv.lib.optionals stdenv.isDarwin [ libicns ];
1617
1718 buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ]
1819 ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa ];
@@ -34,9 +35,25 @@ stdenv.mkDerivation rec {
3435 "OSX_MIN=10.6" # SDL for macOS only supports deploying on 10.6 and above
3536 ];
3637
38+ postBuild = ''
39+ # iconutil on macOS is not available in nixpkgs
40+ png2icns data/osx/AppIcon.icns data/osx/AppIcon.iconset/*
41+ '';
42+
3743 postInstall = ''
3844 wrapProgram $out/bin/cataclysm-tiles \
3945 --add-flags "--datadir $out/share/"
46+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
47+ app=$out/Applications/Cataclysm.app
48+ install -D -m 444 data/osx/Info.plist -t $app/Contents
49+ install -D -m 444 data/osx/AppIcon.icns -t $app/Contents/Resources
50+ mkdir $app/Contents/MacOS
51+ launcher=$app/Contents/MacOS/Cataclysm.sh
52+ cat << SCRIPT > $launcher
53+ #!/bin/sh
54+ $out/bin/cataclysm-tiles
55+ SCRIPT
56+ chmod 555 $launcher
4057 '';
4158
4259 # Disable, possible problems with hydra