From c81ebc88b6302b2a353e374a9cca701aed555750 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Sat, 5 Jul 2025 21:21:15 +0200 Subject: [PATCH 1/4] dynarmic: init at 6.7.0-unstable-2025-03-16 Signed-off-by: Marcin Serwin --- ...keLists-update-mcl-version-to-0.1.13.patch | 29 ++++ ...-Fix-tests-when-using-newer-versions.patch | 27 ++++ pkgs/by-name/dy/dynarmic/package.nix | 145 ++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 pkgs/by-name/dy/dynarmic/0001-CMakeLists-update-mcl-version-to-0.1.13.patch create mode 100644 pkgs/by-name/dy/dynarmic/0001-xbyak-Fix-tests-when-using-newer-versions.patch create mode 100644 pkgs/by-name/dy/dynarmic/package.nix diff --git a/pkgs/by-name/dy/dynarmic/0001-CMakeLists-update-mcl-version-to-0.1.13.patch b/pkgs/by-name/dy/dynarmic/0001-CMakeLists-update-mcl-version-to-0.1.13.patch new file mode 100644 index 000000000000..8f28e58bff85 --- /dev/null +++ b/pkgs/by-name/dy/dynarmic/0001-CMakeLists-update-mcl-version-to-0.1.13.patch @@ -0,0 +1,29 @@ +From cdbf3ba41ddce41d8ae375464e514f72d158ec0b Mon Sep 17 00:00:00 2001 +From: Marcin Serwin +Date: Sat, 5 Jul 2025 22:26:49 +0200 +Subject: [PATCH] CMakeLists: update mcl version to 0.1.13 + +The mcl in externals is already at this version, but it wasn't bumped +here which makes it impossible to use prebuilt mcl. + +Signed-off-by: Marcin Serwin +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e95050da..edd153d0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -145,7 +145,7 @@ set(TSL_ROBIN_MAP_ENABLE_INSTALL ON) + + find_package(Boost 1.57 REQUIRED) + find_package(fmt 9 CONFIG) +-find_package(mcl 0.1.12 EXACT CONFIG) ++find_package(mcl 0.1.13 EXACT CONFIG) + find_package(tsl-robin-map CONFIG) + + if ("arm64" IN_LIST ARCHITECTURE OR DYNARMIC_TESTS) +-- +2.49.0 + diff --git a/pkgs/by-name/dy/dynarmic/0001-xbyak-Fix-tests-when-using-newer-versions.patch b/pkgs/by-name/dy/dynarmic/0001-xbyak-Fix-tests-when-using-newer-versions.patch new file mode 100644 index 000000000000..020f1cfd497e --- /dev/null +++ b/pkgs/by-name/dy/dynarmic/0001-xbyak-Fix-tests-when-using-newer-versions.patch @@ -0,0 +1,27 @@ +From 40e8205b3efd126b9676a783c8306793e61d3f00 Mon Sep 17 00:00:00 2001 +From: Marcin Serwin +Date: Sun, 6 Jul 2025 10:08:26 +0200 +Subject: [PATCH] xbyak: Fix tests when using newer versions + +Signed-off-by: Marcin Serwin +--- + src/dynarmic/CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/dynarmic/CMakeLists.txt b/src/dynarmic/CMakeLists.txt +index 6f0813ca..21a5576c 100644 +--- a/src/dynarmic/CMakeLists.txt ++++ b/src/dynarmic/CMakeLists.txt +@@ -267,6 +267,9 @@ if ("x86_64" IN_LIST ARCHITECTURE) + xbyak::xbyak + Zydis::Zydis + ) ++ # Newer versions of xbyak (>= 7.25.0) have stricter checks that currently ++ # fail in dynarmic ++ target_compile_definitions(dynarmic PRIVATE XBYAK_STRICT_CHECK_MEM_REG_SIZE=0) + + target_architecture_specific_sources(dynarmic "x86_64" + backend/x64/abi.cpp +-- +2.49.0 + diff --git a/pkgs/by-name/dy/dynarmic/package.nix b/pkgs/by-name/dy/dynarmic/package.nix new file mode 100644 index 000000000000..00988dadc887 --- /dev/null +++ b/pkgs/by-name/dy/dynarmic/package.nix @@ -0,0 +1,145 @@ +{ + stdenv, + lib, + fetchFromGitHub, + cmake, + ninja, + boost, + robin-map, + catch2_3, + fmt, + xbyak, + zydis, + nix-update-script, + azahar, + darwin, +}: +let + oaknut = stdenv.mkDerivation { + pname = "oaknut"; + version = "1.2.2-unstable-2024-03-01"; + + src = fetchFromGitHub { + owner = "merryhime"; + repo = "oaknut"; + rev = "94c726ce0338b054eb8cb5ea91de8fe6c19f4392"; + hash = "sha256-IhP/110NGN42/FvpGIEm9MgsSiPYdtD8kNxL0cAWbqM="; + }; + + nativeBuildInputs = [ + cmake + ninja + ]; + }; + + mcl = stdenv.mkDerivation { + pname = "mcl"; + version = "0.1.13-unstable-2025-03-16"; + + src = fetchFromGitHub { + owner = "azahar-emu"; + repo = "mcl"; + rev = "7b08d83418f628b800dfac1c9a16c3f59036fbad"; + hash = "sha256-uTOiOlMzKbZSjKjtVSqFU+9m8v8horoCq3wL0O2E8sI="; + }; + + nativeBuildInputs = [ + cmake + ninja + ]; + + buildInputs = [ + fmt + ]; + + checkInputs = [ + catch2_3 + ]; + + doCheck = true; + checkPhase = '' + tests/mcl-tests + ''; + }; +in +stdenv.mkDerivation (finalAttrs: { + pname = "dynarmic"; + version = "6.7.0-unstable-2025-03-16"; + + src = fetchFromGitHub { + owner = "azahar-emu"; + repo = "dynarmic"; + rev = "278405bd71999ed3f3c77c5f78344a06fef798b9"; + hash = "sha256-D7nXn5y0h8FV0V8Tc8uBlRoeEU+gcpt44afujZvG+1A="; + }; + + patches = [ + # https://github.com/azahar-emu/dynarmic/pull/2 + ./0001-CMakeLists-update-mcl-version-to-0.1.13.patch + # https://github.com/azahar-emu/dynarmic/pull/3 + ./0001-xbyak-Fix-tests-when-using-newer-versions.patch + ]; + + strictDeps = true; + + nativeBuildInputs = + [ + cmake + ninja + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + darwin.DarwinTools # sw_ver + darwin.bootstrap_cmds # mig + ]; + + buildInputs = + [ + boost + robin-map + mcl + fmt + ] + ++ lib.optionals stdenv.hostPlatform.isAarch64 [ + oaknut + ] + ++ lib.optionals stdenv.hostPlatform.isx86_64 [ + xbyak + zydis + ]; + + checkInputs = [ + catch2_3 + oaknut + ]; + + # This changes `ir/opt` to `ir/var/empty` in `CMakeLists.txt` + # making the build fail, as that path does not exist + dontFixCmake = true; + + cmakeFlags = [ + (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) + (lib.cmakeBool "DYNARMIC_TESTS" finalAttrs.finalPackage.doCheck) + ]; + + env = lib.optionalAttrs stdenv.cc.isGNU { + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117063 + NIX_CFLAGS_COMPILE = "-Wno-error=stringop-overread"; + }; + + doCheck = true; + + passthru = { + inherit mcl oaknut; + + updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; }; + tests = { inherit azahar; }; + }; + + meta = { + description = "Dynamic recompiler for ARM"; + homepage = "https://github.com/azahar-emu/dynarmic"; + maintainers = with lib.maintainers; [ marcin-serwin ]; + license = lib.licenses.bsd0; + platforms = with lib.platforms; x86_64 ++ aarch64; + }; +}) From a35da5b1b8b4bb9a295d0e5ad752a0fb34eba949 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Sun, 6 Jul 2025 01:37:19 +0200 Subject: [PATCH 2/4] azahar: use system xbyak and dynarmic Signed-off-by: Marcin Serwin --- pkgs/by-name/az/azahar/package.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/az/azahar/package.nix b/pkgs/by-name/az/azahar/package.nix index 91f5d5517cd8..200143df1ec8 100644 --- a/pkgs/by-name/az/azahar/package.nix +++ b/pkgs/by-name/az/azahar/package.nix @@ -6,6 +6,7 @@ cryptopp, cpp-jwt, doxygen, + dynarmic, enet, fetchpatch, fetchzip, @@ -27,12 +28,14 @@ pipewire, pkg-config, portaudio, + robin-map, SDL2, sndio, spirv-tools, soundtouch, stdenv, vulkan-headers, + xbyak, xorg, zstd, enableQtTranslations ? true, @@ -73,6 +76,7 @@ stdenv.mkDerivation (finalAttrs: { catch2_3 cryptopp cpp-jwt + dynarmic enet fmt ffmpeg_6-headless @@ -89,6 +93,7 @@ stdenv.mkDerivation (finalAttrs: { openssl pipewire portaudio + robin-map qt6.qtbase qt6.qtmultimedia qt6.qttools @@ -98,6 +103,7 @@ stdenv.mkDerivation (finalAttrs: { sndio spirv-tools vulkan-headers + xbyak xorg.libX11 xorg.libXext zstd @@ -121,10 +127,6 @@ stdenv.mkDerivation (finalAttrs: { ]; postPatch = '' - # Fix "file not found" bug when looking in var/empty instead of opt - mkdir externals/dynarmic/src/dynarmic/ir/var - ln -s ../opt externals/dynarmic/src/dynarmic/ir/var/empty - # We already know the submodules are present substituteInPlace CMakeLists.txt \ --replace-fail "check_submodules_present()" "" @@ -136,10 +138,8 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ (cmakeBool "USE_SYSTEM_LIBS" true) - (cmakeBool "DISABLE_SYSTEM_DYNARMIC" true) (cmakeBool "DISABLE_SYSTEM_LODEPNG" true) (cmakeBool "DISABLE_SYSTEM_VMA" true) - (cmakeBool "DISABLE_SYSTEM_XBYAK" true) (cmakeBool "ENABLE_QT_TRANSLATION" enableQtTranslations) (cmakeBool "ENABLE_CUBEB" enableCubeb) (cmakeBool "USE_DISCORD_PRESENCE" useDiscordRichPresence) From 25ce4c87c90437b5023f757a384ca56bdb33b05c Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Sun, 6 Jul 2025 21:42:16 +0200 Subject: [PATCH 3/4] azahar: add marcin-serwin to maintainers Signed-off-by: Marcin Serwin --- pkgs/by-name/az/azahar/package.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/az/azahar/package.nix b/pkgs/by-name/az/azahar/package.nix index 200143df1ec8..9178267fc4f2 100644 --- a/pkgs/by-name/az/azahar/package.nix +++ b/pkgs/by-name/az/azahar/package.nix @@ -150,7 +150,10 @@ stdenv.mkDerivation (finalAttrs: { description = "Open-source 3DS emulator project based on Citra"; homepage = "https://github.com/azahar-emu/azahar"; license = lib.licenses.gpl2Only; - maintainers = with lib.maintainers; [ arthsmn ]; + maintainers = with lib.maintainers; [ + arthsmn + marcin-serwin + ]; mainProgram = "azahar"; }; }) From dbb72a538422be85d0d6e4de571ec7730e183f7a Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Sat, 19 Jul 2025 15:21:29 +0200 Subject: [PATCH 4/4] azahar: fix build on darwin Signed-off-by: Marcin Serwin --- pkgs/by-name/az/azahar/package.nix | 50 +++++++++++-------- .../az/azahar/update-cmake-lists.patch | 43 ++++++++++++++++ 2 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 pkgs/by-name/az/azahar/update-cmake-lists.patch diff --git a/pkgs/by-name/az/azahar/package.nix b/pkgs/by-name/az/azahar/package.nix index 9178267fc4f2..b27eb7adbb65 100644 --- a/pkgs/by-name/az/azahar/package.nix +++ b/pkgs/by-name/az/azahar/package.nix @@ -1,5 +1,4 @@ { - alsa-lib, boost, catch2_3, cmake, @@ -12,16 +11,14 @@ fetchzip, fmt, ffmpeg_6-headless, - gamemode, glslang, httplib, inih, lib, libGL, - libjack2, - libpulseaudio, libunwind, libusb1, + moltenvk, nlohmann_json, openal, openssl, @@ -30,7 +27,6 @@ portaudio, robin-map, SDL2, - sndio, spirv-tools, soundtouch, stdenv, @@ -45,10 +41,13 @@ useDiscordRichPresence ? true, rapidjson, enableSSE42 ? true, # Disable if your hardware doesn't support SSE 4.2 (mainly CPUs before 2011) + gamemode, + enableGamemode ? lib.meta.availableOn stdenv.hostPlatform gamemode, }: let inherit (lib) optionals + optionalString cmakeBool getLib ; @@ -71,7 +70,6 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ - alsa-lib boost catch2_3 cryptopp @@ -84,33 +82,35 @@ stdenv.mkDerivation (finalAttrs: { httplib inih libGL - libjack2 - libpulseaudio libunwind libusb1 nlohmann_json openal openssl - pipewire portaudio robin-map qt6.qtbase qt6.qtmultimedia qt6.qttools - qt6.qtwayland soundtouch SDL2 - sndio spirv-tools vulkan-headers xbyak - xorg.libX11 - xorg.libXext zstd ] ++ optionals enableQtTranslations [ qt6.qttools ] ++ optionals enableCubeb [ cubeb ] - ++ optionals useDiscordRichPresence [ rapidjson ]; + ++ optionals useDiscordRichPresence [ rapidjson ] + ++ optionals stdenv.hostPlatform.isLinux [ + pipewire + qt6.qtwayland + xorg.libX11 + xorg.libXext + ] + ++ optionals stdenv.hostPlatform.isDarwin [ + moltenvk + ]; patches = [ # Fix boost errors @@ -124,17 +124,22 @@ stdenv.mkDerivation (finalAttrs: { url = "https://raw.githubusercontent.com/Tatsh/tatsh-overlay/5c4497d9b67fa6f2fa327b2f2ce4cb5be8c9f2f7/games-emulation/lime3ds/files/lime3ds-0003-boost-1.87-fixes.patch"; hash = "sha256-mwfI7fTx9aWF/EjMW3bxoz++A+6ONbNA70tT5nkhDUU="; }) + + # https://github.com/azahar-emu/azahar/pull/1165 + ./update-cmake-lists.patch ]; - postPatch = '' - # We already know the submodules are present - substituteInPlace CMakeLists.txt \ - --replace-fail "check_submodules_present()" "" - + postPatch = + '' + # We already know the submodules are present + substituteInPlace CMakeLists.txt \ + --replace-fail "check_submodules_present()" "" + '' # Add gamemode - substituteInPlace externals/gamemode/include/gamemode_client.h \ - --replace-fail "libgamemode.so.0" "${getLib gamemode}/lib/libgamemode.so.0" - ''; + + optionalString enableGamemode '' + substituteInPlace externals/gamemode/include/gamemode_client.h \ + --replace-fail "libgamemode.so.0" "${getLib gamemode}/lib/libgamemode.so.0" + ''; cmakeFlags = [ (cmakeBool "USE_SYSTEM_LIBS" true) @@ -155,5 +160,6 @@ stdenv.mkDerivation (finalAttrs: { marcin-serwin ]; mainProgram = "azahar"; + platforms = with lib.platforms; linux ++ darwin; }; }) diff --git a/pkgs/by-name/az/azahar/update-cmake-lists.patch b/pkgs/by-name/az/azahar/update-cmake-lists.patch new file mode 100644 index 000000000000..4759d4c26d02 --- /dev/null +++ b/pkgs/by-name/az/azahar/update-cmake-lists.patch @@ -0,0 +1,43 @@ +From d9e7361a174f0f491c49fe78cd96a823c65e97dd Mon Sep 17 00:00:00 2001 +From: qr243vbi +Date: Sat, 7 Jun 2025 01:18:03 +0300 +Subject: [PATCH 1/2] Update CMakeLists.txt + +--- + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 54051a4ef2..531c46abbe 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -16,6 +16,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules") + include(DownloadExternals) + include(CMakeDependentOption) ++include(FindPkgConfig) + + project(citra LANGUAGES C CXX ASM) + + +From 679a4036e2fbb96d1d6a803f3f59ae8f01f9e691 Mon Sep 17 00:00:00 2001 +From: qr243vbi +Date: Sat, 7 Jun 2025 12:49:07 +0300 +Subject: [PATCH 2/2] Add missing find_package directive + +--- + src/citra_qt/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt +index 1b78605a0a..de00dc4609 100644 +--- a/src/citra_qt/CMakeLists.txt ++++ b/src/citra_qt/CMakeLists.txt +@@ -273,6 +273,7 @@ if (ENABLE_VULKAN) + endif() + + if (NOT WIN32) ++ find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + target_include_directories(citra_qt PRIVATE ${Qt6Gui_PRIVATE_INCLUDE_DIRS}) + endif() +