From 6b4c7368fa83180853063373a5b7e332fe44363c Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 5 Mar 2022 01:00:30 +0000 Subject: [PATCH] retroarchBare: re-add support to Darwin This still doesn't fix our wrapped retroarch binary, but should be sufficient to build retroarch+cores in Darwin. --- .../emulators/retroarch/default.nix | 23 ++++++++++++++++--- .../emulators/retroarch/wrapper.nix | 16 ++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/pkgs/applications/emulators/retroarch/default.nix b/pkgs/applications/emulators/retroarch/default.nix index 2c49874e5446..c8d8394661dc 100644 --- a/pkgs/applications/emulators/retroarch/default.nix +++ b/pkgs/applications/emulators/retroarch/default.nix @@ -104,10 +104,30 @@ stdenv.mkDerivation rec { '' + lib.optionalString (runtimeLibs != [ ]) '' wrapProgram $out/bin/retroarch \ --prefix LD_LIBRARY_PATH ':' ${lib.makeLibraryPath runtimeLibs} + '' + lib.optionalString stdenv.isDarwin '' + # https://github.com/libretro/RetroArch/blob/master/retroarch-apple-packaging.sh + app=$out/Applications/RetroArch.app + mkdir -p $app/Contents/MacOS + cp -r pkg/apple/OSX/* $app/Contents + cp $out/bin/retroarch $app/Contents/MacOS + # FIXME: using Info_Metal.plist results in input not working + # mv $app/Contents/Info_Metal.plist $app/Contents/Info.plist + + substituteInPlace $app/Contents/Info.plist \ + --replace '${"\${EXECUTABLE_NAME}"}' 'RetroArch' \ + --replace '$(PRODUCT_BUNDLE_IDENTIFIER)' 'com.libretro.RetroArch' \ + --replace '${"\${PRODUCT_NAME}"}' 'RetroArch' \ + --replace '${"\${MACOSX_DEPLOYMENT_TARGET}"}' '10.13' + + cp media/retroarch.icns $app/Contents/Resources/ ''; preFixup = "rm $out/bin/retroarch-cg2glsl"; + # Workaround for the following error affecting newer versions of Clang: + # ./config.def.h:xxx:x: error: 'TARGET_OS_TV' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_] + NIX_CFLAGS_COMPILE = lib.optional stdenv.cc.isClang [ "-Wno-undef-prefix" ]; + meta = with lib; { homepage = "https://libretro.com"; description = "Multi-platform emulator frontend for libretro cores"; @@ -115,8 +135,5 @@ stdenv.mkDerivation rec { platforms = platforms.unix; changelog = "https://github.com/libretro/RetroArch/blob/v${version}/CHANGES.md"; maintainers = with maintainers; [ MP2E edwtjo matthewbauer kolbycrouch thiagokokada ]; - # FIXME: exits with error on macOS: - # No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting - broken = stdenv.isDarwin; }; } diff --git a/pkgs/applications/emulators/retroarch/wrapper.nix b/pkgs/applications/emulators/retroarch/wrapper.nix index b3797c9e9e36..6adcb8ffd8b4 100644 --- a/pkgs/applications/emulators/retroarch/wrapper.nix +++ b/pkgs/applications/emulators/retroarch/wrapper.nix @@ -8,8 +8,7 @@ stdenv.mkDerivation { buildCommand = '' mkdir -p $out/lib - for coreDir in $cores - do + for coreDir in $cores; do ln -s $coreDir/* $out/lib/. done @@ -29,9 +28,14 @@ stdenv.mkDerivation { meta = with retroarch.meta; { inherit changelog description homepage license maintainers platforms; - longDescription = - "RetroArch is the reference frontend for the libretro API. The following cores are included: " - + lib.concatStringsSep ", " (map (x: "${x.name}") cores) - + "."; + longDescription = '' + RetroArch is the reference frontend for the libretro API. + + The following cores are included: + ${lib.concatStringsSep "\n" (map (x: " - ${x.name}") cores)} + ''; + # FIXME: exits with error on macOS: + # No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting + broken = stdenv.isDarwin; }; }