about summary refs log tree commit diff
path: root/pkgs/games/bugdom
diff options
context:
space:
mode:
authorOPNA2608 <christoph.neidahl@gmail.com>2022-04-05 23:57:06 +0200
committerOPNA2608 <christoph.neidahl@gmail.com>2022-04-05 23:57:06 +0200
commitb75018a78939f48250e7286bcf93820e93cfa713 (patch)
tree68f1958b706c44a367221c51ccad8ea95ef8a445 /pkgs/games/bugdom
parent4097e922f6e877fccb1fd96a54ad09d0d9bf26ed (diff)
bugdom: Enable on Darwin
Diffstat (limited to 'pkgs/games/bugdom')
-rw-r--r--pkgs/games/bugdom/default.nix26
1 files changed, 24 insertions, 2 deletions
diff --git a/pkgs/games/bugdom/default.nix b/pkgs/games/bugdom/default.nix
index 57a1e41409023..c5170c9845cca 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;
   };
 }