git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #34107 from mnacamura/cdda-darwin

cataclysm-dda{,-git}: build on Darwin

commitbeb70f1370bd1a35e473ff0cc489e057b5432fd2 authorMichael Raskin <7c6f434c@mail.ru> dateMon 22 Jan 2018, 22:47 (9 years ago) parenta03b2b9cf8cd83
5 files changed+98−11
pkgs/games/cataclysm-dda/default.nix+30−5 pkgs/games/cataclysm-dda/git.nix+22−4 pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch+20 pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch+20 pkgs/top-level/all-packages.nix+6−2
pkgs/games/cataclysm-dda/default.nix+30−5
@@ -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}
pkgs/games/cataclysm-dda/git.nix+22−4
@@ -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, CoreFoundation, Cocoa }:
33
44stdenv.mkDerivation rec {
55 version = "2017-12-09";
@@ -14,7 +14,10 @@ stdenv.mkDerivation rec {
1414
1515 nativeBuildInputs = [ makeWrapper pkgconfig ];
1616
17− buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ];
17+ buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ]
18+ ++ stdenv.lib.optionals stdenv.isDarwin [ CoreFoundation Cocoa ];
19+
20+ patches = [ ./patches/fix_locale_dir_git.patch ];
1821
1922 postPatch = ''
2023 patchShebangs .
@@ -26,11 +29,26 @@ stdenv.mkDerivation rec {
2629 -i src/{crafting,skill,weather_data,melee,vehicle,overmap,iuse_actor}.cpp
2730 '';
2831
29− makeFlags = "PREFIX=$(out) LUA=1 TILES=1 SOUND=1 RELEASE=1 USE_HOME_DIR=1";
32+ makeFlags = [
33+ "PREFIX=$(out) LUA=1 TILES=1 SOUND=1 RELEASE=1 USE_HOME_DIR=1"
34+ ] ++ stdenv.lib.optionals stdenv.isDarwin [
35+ "NATIVE=osx CLANG=1"
36+ ];
3037
3138 postInstall = ''
3239 wrapProgram $out/bin/cataclysm-tiles \
3340 --add-flags "--datadir $out/share/cataclysm-dda/"
41+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
42+ app=$out/Applications/Cataclysm.app
43+ install -D -m 444 data/osx/Info.plist -t $app/Contents
44+ install -D -m 444 data/osx/AppIcon.icns -t $app/Contents/Resources
45+ mkdir $app/Contents/MacOS
46+ launcher=$app/Contents/MacOS/Cataclysm.sh
47+ cat << SCRIPT > $launcher
48+ #!/bin/sh
49+ $out/bin/cataclysm-tiles
50+ SCRIPT
51+ chmod 555 $launcher
3452 '';
3553
3654 # https://hydra.nixos.org/build/65193254
@@ -65,6 +83,6 @@ stdenv.mkDerivation rec {
6583 '';
6684 homepage = http://en.cataclysmdda.com/;
6785 license = licenses.cc-by-sa-30;
68− platforms = platforms.linux;
86+ platforms = platforms.unix;
6987 };
7088}
pkgs/games/cataclysm-dda/patches/fix_locale_dir.patchnew file+20
@@ -0,0 +1,20 @@
1+diff --git a/src/translations.cpp b/src/translations.cpp
2+index 6520cfe..49f7b2c 100644
3+--- a/src/translations.cpp
4++++ b/src/translations.cpp
5+@@ -72,15 +72,11 @@ void set_language(bool reload_options)
6+
7+ // Step 2. Bind to gettext domain.
8+ const char *locale_dir;
9+-#ifdef __linux__
10+ if (!FILENAMES["base_path"].empty()) {
11+ locale_dir = std::string(FILENAMES["base_path"] + "share/locale").c_str();
12+ } else {
13+ locale_dir = "lang/mo";
14+ }
15+-#else
16+- locale_dir = "lang/mo";
17+-#endif // __linux__
18+
19+ bindtextdomain("cataclysm-dda", locale_dir);
20+ bind_textdomain_codeset("cataclysm-dda", "UTF-8");
pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patchnew file+20
@@ -0,0 +1,20 @@
1+diff --git a/src/translations.cpp b/src/translations.cpp
2+index 3a86291..e6c5f84 100644
3+--- a/src/translations.cpp
4++++ b/src/translations.cpp
5+@@ -176,15 +176,11 @@ void set_language()
6+
7+ // Step 2. Bind to gettext domain.
8+ std::string locale_dir;
9+-#if (defined __linux__ || (defined MACOSX && !defined TILES))
10+ if( !FILENAMES["base_path"].empty() ) {
11+ locale_dir = FILENAMES["base_path"] + "share/locale";
12+ } else {
13+ locale_dir = "lang/mo";
14+ }
15+-#else
16+- locale_dir = "lang/mo";
17+-#endif // __linux__
18+
19+ const char *locale_dir_char = locale_dir.c_str();
20+ bindtextdomain( "cataclysm-dda", locale_dir_char );
pkgs/top-level/all-packages.nix+6−2
@@ -18148,9 +18148,13 @@ with pkgs;
1814818148
1814918149 bzflag = callPackage ../games/bzflag { };
1815018150
18151− cataclysm-dda = callPackage ../games/cataclysm-dda { };
18151+ cataclysm-dda = callPackage ../games/cataclysm-dda {
18152+ inherit (darwin.apple_sdk.frameworks) Cocoa;
18153+ };
1815218154
18153− cataclysm-dda-git = callPackage ../games/cataclysm-dda/git.nix { };
18155+ cataclysm-dda-git = callPackage ../games/cataclysm-dda/git.nix {
18156+ inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
18157+ };
1815418158
1815518159 chessdb = callPackage ../games/chessdb { };
1815618160