From 6be1c77f05332b635eef7a3e9d8c789eeb5291b8 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Wed, 28 Dec 2022 06:31:27 +0100 Subject: [PATCH] ares: add darwin support --- .../bsnes/ares/002-sips-to-png2icns.patch | 39 +++++++++++++++++++ .../bsnes/ares/003-fix-darwin-install.patch | 23 +++++++++++ .../emulators/bsnes/ares/default.nix | 24 ++++++++++-- pkgs/top-level/all-packages.nix | 4 +- 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 pkgs/applications/emulators/bsnes/ares/002-sips-to-png2icns.patch create mode 100644 pkgs/applications/emulators/bsnes/ares/003-fix-darwin-install.patch diff --git a/pkgs/applications/emulators/bsnes/ares/002-sips-to-png2icns.patch b/pkgs/applications/emulators/bsnes/ares/002-sips-to-png2icns.patch new file mode 100644 index 0000000000000..4c2259d63a335 --- /dev/null +++ b/pkgs/applications/emulators/bsnes/ares/002-sips-to-png2icns.patch @@ -0,0 +1,39 @@ +diff --git a/desktop-ui/GNUmakefile b/desktop-ui/GNUmakefile +index 4515610d3..916c8fcd8 100644 +--- a/desktop-ui/GNUmakefile ++++ b/desktop-ui/GNUmakefile +@@ -91,7 +91,7 @@ endif + cp resource/$(name).plist $(output.path)/$(name).app/Contents/Info.plist + cp -R $(ares.path)/Shaders $(output.path)/$(name).app/Contents/Resources/ + cp -R $(mia.path)/Database $(output.path)/$(name).app/Contents/Resources/ +- sips -s format icns resource/$(name).png --out $(output.path)/$(name).app/Contents/Resources/$(name).icns ++ png2icns $(output.path)/$(name).app/Contents/Resources/$(name).icns resource/$(name).png + codesign --force --deep --options runtime --entitlements resource/$(name).selfsigned.entitlements --sign - $(output.path)/$(name).app + else ifeq ($(platform),windows) + $(call mkdir,$(output.path)/Shaders/) +diff --git a/genius/GNUmakefile b/genius/GNUmakefile +index 5287309a8..8d80f9306 100644 +--- a/genius/GNUmakefile ++++ b/genius/GNUmakefile +@@ -24,7 +24,7 @@ ifeq ($(platform),macos) + mkdir -p $(output.path)/$(name).app/Contents/Resources/ + mv $(output.path)/$(name) $(output.path)/$(name).app/Contents/MacOS/$(name) + cp data/$(name).plist $(output.path)/$(name).app/Contents/Info.plist +- sips -s format icns data/$(name).png --$(output.path) $(output.path)/$(name).app/Contents/Resources/$(name).icns ++ png2icns $(output.path)/$(name).app/Contents/Resources/$(name).icns data/$(name).png + endif + + verbose: hiro.verbose nall.verbose all; +diff --git a/mia/GNUmakefile b/mia/GNUmakefile +index b6930b6df..7a51b5028 100644 +--- a/mia/GNUmakefile ++++ b/mia/GNUmakefile +@@ -32,7 +32,7 @@ ifeq ($(platform),macos) + mkdir -p $(output.path)/$(name).app/Contents/Resources/ + mv $(output.path)/$(name) $(output.path)/$(name).app/Contents/MacOS/$(name) + cp resource/$(name).plist $(output.path)/$(name).app/Contents/Info.plist +- sips -s format icns resource/$(name).png --out $(output.path)/$(name).app/Contents/Resources/$(name).icns ++ png2icns $(output.path)/$(name).app/Contents/Resources/$(name).icns resource/$(name).png + endif + + verbose: hiro.verbose nall.verbose all; diff --git a/pkgs/applications/emulators/bsnes/ares/003-fix-darwin-install.patch b/pkgs/applications/emulators/bsnes/ares/003-fix-darwin-install.patch new file mode 100644 index 0000000000000..5b216ac267e20 --- /dev/null +++ b/pkgs/applications/emulators/bsnes/ares/003-fix-darwin-install.patch @@ -0,0 +1,23 @@ +diff --git a/desktop-ui/GNUmakefile b/desktop-ui/GNUmakefile +index 916c8fcd8..b767c1335 100644 +--- a/desktop-ui/GNUmakefile ++++ b/desktop-ui/GNUmakefile +@@ -92,7 +92,6 @@ endif + cp -R $(ares.path)/Shaders $(output.path)/$(name).app/Contents/Resources/ + cp -R $(mia.path)/Database $(output.path)/$(name).app/Contents/Resources/ + png2icns $(output.path)/$(name).app/Contents/Resources/$(name).icns resource/$(name).png +- codesign --force --deep --options runtime --entitlements resource/$(name).selfsigned.entitlements --sign - $(output.path)/$(name).app + else ifeq ($(platform),windows) + $(call mkdir,$(output.path)/Shaders/) + $(call mkdir,$(output.path)/Database/) +@@ -115,8 +114,8 @@ ifeq ($(platform),windows) + else ifeq ($(shell id -un),root) + $(error "make install should not be run as root") + else ifeq ($(platform),macos) +- mkdir -p ~/Library/Application\ Support/$(name)/ +- cp -R $(output.path)/$(name).app /Applications/$(name).app ++ mkdir -p $(prefix)/Applications/ ++ cp -R $(output.path)/$(name).app $(prefix)/Applications/$(name).app + else ifneq ($(filter $(platform),linux bsd),) + mkdir -p $(prefix)/bin/ + mkdir -p $(prefix)/share/applications/ diff --git a/pkgs/applications/emulators/bsnes/ares/default.nix b/pkgs/applications/emulators/bsnes/ares/default.nix index 7a6dae5784cec..e69befe7de504 100644 --- a/pkgs/applications/emulators/bsnes/ares/default.nix +++ b/pkgs/applications/emulators/bsnes/ares/default.nix @@ -3,6 +3,7 @@ , fetchFromGitHub , pkg-config , wrapGAppsHook +, libicns , SDL2 , alsa-lib , gtk3 @@ -15,6 +16,8 @@ , libpulseaudio , openal , udev +, Cocoa +, OpenAL }: stdenv.mkDerivation (finalAttrs: { @@ -31,15 +34,21 @@ stdenv.mkDerivation (finalAttrs: { patches = [ ./000-dont-rebuild-on-install.patch ./001-fix-ruby.patch + ./002-sips-to-png2icns.patch + ./003-fix-darwin-install.patch ]; nativeBuildInputs = [ pkg-config wrapGAppsHook + ] ++ lib.optionals stdenv.isDarwin [ + libicns ]; buildInputs = [ SDL2 + libao + ] ++ lib.optionals stdenv.isLinux [ alsa-lib gtk3 gtksourceview3 @@ -47,29 +56,36 @@ stdenv.mkDerivation (finalAttrs: { libGLU libX11 libXv - libao libpulseaudio openal udev + ] ++ lib.optionals stdenv.isDarwin [ + Cocoa + OpenAL ]; enableParallelBuilding = true; - makeFlags = [ + makeFlags = lib.optionals stdenv.isLinux [ "hiro=gtk3" + ] ++ lib.optionals stdenv.isDarwin [ + "hiro=cocoa" + "vulkan=false" + ] ++ [ "local=false" "openmp=true" "prefix=$(out)" "-C desktop-ui" ]; + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-mmacosx-version-min=10.14"; + meta = with lib; { homepage = "https://ares-emu.net"; description = "Open-source multi-system emulator with a focus on accuracy and preservation"; license = licenses.isc; maintainers = with maintainers; [ Madouura AndersonTorres ]; - platforms = platforms.linux; + platforms = platforms.unix; }; }) # TODO: select between Qt, GTK2 and GTK3 -# TODO: support Darwin diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9b260e9ac45aa..f9d6a174f6751 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2162,7 +2162,9 @@ with pkgs; ### APPLICATIONS/EMULATORS/BSNES - ares = callPackage ../applications/emulators/bsnes/ares { }; + ares = darwin.apple_sdk_11_0.callPackage ../applications/emulators/bsnes/ares { + inherit (darwin.apple_sdk_11_0.frameworks) Cocoa OpenAL; + }; bsnes-hd = callPackage ../applications/emulators/bsnes/bsnes-hd { inherit (darwin.apple_sdk.frameworks) Cocoa OpenAL;