From 7287a9e91d9702fbec8899e7f6ffad7551a0f269 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Nakamura Date: Mon, 22 Jan 2018 12:19:27 +0900 Subject: [PATCH] cataclysm-dda{,-git}: create app launcher on Darwin --- pkgs/games/cataclysm-dda/default.nix | 21 +++++++++++++++++++-- pkgs/games/cataclysm-dda/git.nix | 11 +++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/pkgs/games/cataclysm-dda/default.nix b/pkgs/games/cataclysm-dda/default.nix index 65ed964ba998..c5e17473b490 100644 --- a/pkgs/games/cataclysm-dda/default.nix +++ b/pkgs/games/cataclysm-dda/default.nix @@ -1,5 +1,5 @@ { fetchFromGitHub, stdenv, makeWrapper, pkgconfig, ncurses, lua, SDL2, SDL2_image, SDL2_ttf, -SDL2_mixer, freetype, gettext, Cocoa }: +SDL2_mixer, freetype, gettext, Cocoa, libicns }: stdenv.mkDerivation rec { version = "0.C"; @@ -12,7 +12,8 @@ stdenv.mkDerivation rec { sha256 = "03sdzsk4qdq99qckq0axbsvg1apn6xizscd8pwp5w6kq2fyj5xkv"; }; - nativeBuildInputs = [ makeWrapper pkgconfig ]; + nativeBuildInputs = [ makeWrapper pkgconfig ] + ++ stdenv.lib.optionals stdenv.isDarwin [ libicns ]; buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ] ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa ]; @@ -34,9 +35,25 @@ stdenv.mkDerivation rec { "OSX_MIN=10.6" # SDL for macOS only supports deploying on 10.6 and above ]; + postBuild = '' + # iconutil on macOS is not available in nixpkgs + png2icns data/osx/AppIcon.icns data/osx/AppIcon.iconset/* + ''; + postInstall = '' wrapProgram $out/bin/cataclysm-tiles \ --add-flags "--datadir $out/share/" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + app=$out/Applications/Cataclysm.app + install -D -m 444 data/osx/Info.plist -t $app/Contents + install -D -m 444 data/osx/AppIcon.icns -t $app/Contents/Resources + mkdir $app/Contents/MacOS + launcher=$app/Contents/MacOS/Cataclysm.sh + cat << SCRIPT > $launcher + #!/bin/sh + $out/bin/cataclysm-tiles + SCRIPT + chmod 555 $launcher ''; # Disable, possible problems with hydra diff --git a/pkgs/games/cataclysm-dda/git.nix b/pkgs/games/cataclysm-dda/git.nix index 7d79b1347861..3162f2ecb259 100644 --- a/pkgs/games/cataclysm-dda/git.nix +++ b/pkgs/games/cataclysm-dda/git.nix @@ -36,6 +36,17 @@ stdenv.mkDerivation rec { postInstall = '' wrapProgram $out/bin/cataclysm-tiles \ --add-flags "--datadir $out/share/cataclysm-dda/" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + app=$out/Applications/Cataclysm.app + install -D -m 444 data/osx/Info.plist -t $app/Contents + install -D -m 444 data/osx/AppIcon.icns -t $app/Contents/Resources + mkdir $app/Contents/MacOS + launcher=$app/Contents/MacOS/Cataclysm.sh + cat << SCRIPT > $launcher + #!/bin/sh + $out/bin/cataclysm-tiles + SCRIPT + chmod 555 $launcher ''; # https://hydra.nixos.org/build/65193254