From b75018a78939f48250e7286bcf93820e93cfa713 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Tue, 5 Apr 2022 23:57:06 +0200 Subject: [PATCH] bugdom: Enable on Darwin --- pkgs/games/bugdom/default.nix | 26 ++++++++++++++++++++++++-- pkgs/top-level/all-packages.nix | 4 +++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/pkgs/games/bugdom/default.nix b/pkgs/games/bugdom/default.nix index 57a1e4140902..c5170c9845cc 100644 --- a/pkgs/games/bugdom/default.nix +++ b/pkgs/games/bugdom/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, SDL2, cmake, makeWrapper }: +{ lib, stdenv, fetchFromGitHub, SDL2, IOKit, Foundation, cmake, makeWrapper }: stdenv.mkDerivation rec { pname = "bugdom"; @@ -12,8 +12,18 @@ stdenv.mkDerivation rec { fetchSubmodules = true; }; + postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' + # Expects SDL2.framework in specific location, which we don't have + # Passing this in cmakeFlags doesn't work because the path is hard-coded for Darwin + substituteInPlace cmake/FindSDL2.cmake \ + --replace 'set(SDL2_LIBRARIES' 'set(SDL2_LIBRARIES "${SDL2}/lib/libSDL2.dylib") #' + ''; + buildInputs = [ SDL2 + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ + IOKit + Foundation ]; nativeBuildInputs = [ @@ -21,13 +31,25 @@ stdenv.mkDerivation rec { makeWrapper ]; + cmakeFlags = lib.optionals stdenv.hostPlatform.isDarwin [ + "-DCMAKE_OSX_ARCHITECTURES=${stdenv.hostPlatform.darwinArch}" + # Expects SDL2.framework in specific location, which we don't have + "-DSDL2_INCLUDE_DIRS=${SDL2.dev}/include/SDL2" + ]; + installPhase = '' runHook preInstall + '' + (if stdenv.hostPlatform.isDarwin then '' + mkdir -p $out/{bin,Applications} + mv {,$out/Applications/}Bugdom.app + ln -s $out/{Applications/Bugdom.app/Contents/MacOS,bin}/Bugdom + '' else '' mkdir -p $out/share/bugdom mv Data $out/share/bugdom install -Dm755 {.,$out/bin}/Bugdom wrapProgram $out/bin/Bugdom --run "cd $out/share/bugdom" + '') + '' runHook postInstall ''; @@ -39,6 +61,6 @@ stdenv.mkDerivation rec { cc-by-sa-40 ]; maintainers = with maintainers; [ lux ]; - platforms = platforms.linux; + platforms = platforms.unix; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 21345ef8d88a..9ea42e7ebd54 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -31003,7 +31003,9 @@ with pkgs; btanks = callPackage ../games/btanks { }; - bugdom = callPackage ../games/bugdom { }; + bugdom = callPackage ../games/bugdom { + inherit (darwin.apple_sdk.frameworks) IOKit Foundation; + }; bzflag = callPackage ../games/bzflag { inherit (darwin.apple_sdk.frameworks) Carbon CoreServices;