@@ -1,5 +1,5 @@
11{ fetchFromGitHub, stdenv, makeWrapper, pkgconfig, ncurses, lua, SDL2, SDL2_image, SDL2_ttf,
2−SDL2_mixer, freetype, gettext }:
2+SDL2_mixer, freetype, gettext, Cocoa, libicns }:
33
44stdenv.mkDerivation rec {
55 version = "0.C";
@@ -12,9 +12,13 @@ stdenv.mkDerivation rec {
1212 sha256 = "03sdzsk4qdq99qckq0axbsvg1apn6xizscd8pwp5w6kq2fyj5xkv";
1313 };
1414
15− nativeBuildInputs = [ makeWrapper pkgconfig ];
15+ nativeBuildInputs = [ makeWrapper pkgconfig ]
16+ ++ stdenv.lib.optionals stdenv.isDarwin [ libicns ];
1617
17− buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ];
18+ buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ]
19+ ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa ];
20+
21+ patches = [ ./patches/fix_locale_dir.patch ];
1822
1923 postPatch = ''
2024 patchShebangs .
@@ -26,11 +30,32 @@ stdenv.mkDerivation rec {
2630 -i src/{crafting,skill,weather_data,melee,vehicle,overmap,iuse_actor}.cpp
2731 '';
2832
29− makeFlags = "PREFIX=$(out) LUA=1 TILES=1 SOUND=1 RELEASE=1 USE_HOME_DIR=1";
33+ makeFlags = [
34+ "PREFIX=$(out) LUA=1 TILES=1 SOUND=1 RELEASE=1 USE_HOME_DIR=1"
35+ ] ++ stdenv.lib.optionals stdenv.isDarwin [
36+ "NATIVE=osx CLANG=1"
37+ "OSX_MIN=10.6" # SDL for macOS only supports deploying on 10.6 and above
38+ ];
39+
40+ postBuild = stdenv.lib.optionalString stdenv.isDarwin ''
41+ # iconutil on macOS is not available in nixpkgs
42+ png2icns data/osx/AppIcon.icns data/osx/AppIcon.iconset/*
43+ '';
3044
3145 postInstall = ''
3246 wrapProgram $out/bin/cataclysm-tiles \
3347 --add-flags "--datadir $out/share/"
48+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
49+ app=$out/Applications/Cataclysm.app
50+ install -D -m 444 data/osx/Info.plist -t $app/Contents
51+ install -D -m 444 data/osx/AppIcon.icns -t $app/Contents/Resources
52+ mkdir $app/Contents/MacOS
53+ launcher=$app/Contents/MacOS/Cataclysm.sh
54+ cat << SCRIPT > $launcher
55+ #!/bin/sh
56+ $out/bin/cataclysm-tiles
57+ SCRIPT
58+ chmod 555 $launcher
3459 '';
3560
3661 # Disable, possible problems with hydra
@@ -64,6 +89,6 @@ stdenv.mkDerivation rec {
6489 homepage = http://en.cataclysmdda.com/;
6590 license = licenses.cc-by-sa-30;
6691 maintainers = [ maintainers.skeidel ];
67− platforms = platforms.linux;
92+ platforms = platforms.unix;
6893 };
6994}