summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2021-05-16 22:59:10 +0000
committerGitHub <noreply@github.com>2021-05-16 22:59:10 +0000
commit5e9437ef57565b80d2f446de0e1fbd566d6868cc (patch)
treeb475297bb6d02d78546baf7f17a01b36a87825eb /pkgs/games
parentf867062ef9e2b862f397d7a38f4899667a7be2d3 (diff)
parentf2a29c1ee93b9f0ab9077704f5e1699b964b1978 (diff)
Merge pull request #123289 from OPNA2608/fix/supertuxkart-darwin/21.05
superTuxKart: Build on Darwin
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/super-tux-kart/default.nix33
1 files changed, 23 insertions, 10 deletions
diff --git a/pkgs/games/super-tux-kart/default.nix b/pkgs/games/super-tux-kart/default.nix
index 7998e13817d87..3589e10e7a533 100644
--- a/pkgs/games/super-tux-kart/default.nix
+++ b/pkgs/games/super-tux-kart/default.nix
@@ -9,18 +9,19 @@
 , SDL2
 , glew
 , openal
+, OpenAL
 , libvorbis
 , libogg
 , curl
 , freetype
-, bluez
 , libjpeg
 , libpng
-, enet
 , harfbuzz
 , mcpp
 , wiiuse
 , angelscript
+, Cocoa
+, IOKit
 }:
 let
   dir = "stk-code";
@@ -82,10 +83,14 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  # Deletes all bundled libs in stk-code/lib except those
-  # That couldn't be replaced with system packages
   postPatch = ''
+    # Deletes all bundled libs in stk-code/lib except those
+    # That couldn't be replaced with system packages
     find lib -maxdepth 1 -type d | egrep -v "^lib$|${(lib.concatStringsSep "|" bundledLibraries)}" | xargs -n1 -L1 -r -I{} rm -rf {}
+
+    # Allow building with system-installed wiiuse on Darwin
+    substituteInPlace CMakeLists.txt \
+      --replace 'NOT (APPLE OR HAIKU)) AND USE_SYSTEM_WIIUSE' 'NOT (HAIKU)) AND USE_SYSTEM_WIIUSE'
   '';
 
   nativeBuildInputs = [ cmake pkg-config makeWrapper ];
@@ -93,20 +98,19 @@ stdenv.mkDerivation rec {
   buildInputs = [
     SDL2
     glew
-    openal
     libvorbis
     libogg
     freetype
     curl
-    bluez
     libjpeg
     libpng
-    enet
     harfbuzz
     mcpp
     wiiuse
   ]
-  ++ lib.optional (!stdenv.hostPlatform.isAarch64) angelscript;
+  ++ lib.optional (!stdenv.hostPlatform.isAarch64) angelscript
+  ++ lib.optional stdenv.hostPlatform.isLinux openal
+  ++ lib.optionals stdenv.hostPlatform.isDarwin [ OpenAL IOKit Cocoa ];
 
   cmakeFlags = [
     "-DBUILD_RECORDER=OFF" # libopenglrecorder is not in nixpkgs
@@ -117,9 +121,18 @@ stdenv.mkDerivation rec {
     "-DOpenGL_GL_PREFERENCE=GLVND"
   ];
 
+  # Extract binary from built app bundle
+  postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
+    mkdir $out/bin
+    mv $out/{supertuxkart.app/Contents/MacOS,bin}/supertuxkart
+    rm -rf $out/supertuxkart.app
+  '';
+
   # Obtain the assets directly from the fetched store path, to avoid duplicating assets across multiple engine builds
   preFixup = ''
-    wrapProgram $out/bin/supertuxkart --set-default SUPERTUXKART_ASSETS_DIR "${assets}"
+    wrapProgram $out/bin/supertuxkart \
+      --set-default SUPERTUXKART_ASSETS_DIR "${assets}" \
+      --set-default SUPERTUXKART_DATADIR "$out/share/supertuxkart" \
   '';
 
   meta = with lib; {
@@ -132,7 +145,7 @@ stdenv.mkDerivation rec {
     homepage = "https://supertuxkart.net/";
     license = licenses.gpl2Plus;
     maintainers = with maintainers; [ pyrolagus peterhoeg ];
-    platforms = with platforms; linux;
+    platforms = with platforms; unix;
     changelog = "https://github.com/supertuxkart/stk-code/blob/${version}/CHANGELOG.md";
   };
 }