From 709d5b4e5c3554764aea4cb01dbb3f1f305e0974 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Sat, 24 May 2025 18:17:21 +0200 Subject: [PATCH] duckstation: use cubeb from nixpkgs Signed-off-by: Marcin Serwin --- pkgs/by-name/du/duckstation/package.nix | 19 +++++------- .../du/duckstation/remove-cubeb-vendor.patch | 29 +++++++++++++++++++ pkgs/by-name/du/duckstation/sources.nix | 12 ++++++++ 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 pkgs/by-name/du/duckstation/remove-cubeb-vendor.patch diff --git a/pkgs/by-name/du/duckstation/package.nix b/pkgs/by-name/du/duckstation/package.nix index 7f5705a5bd7c..e4c39a397c6a 100644 --- a/pkgs/by-name/du/duckstation/package.nix +++ b/pkgs/by-name/du/duckstation/package.nix @@ -6,9 +6,7 @@ callPackage, cmake, cpuinfo, - cubeb, curl, - discord-rpc, extra-cmake-modules, libXrandr, libbacktrace, @@ -42,6 +40,7 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: { ./002-hardcode-vars.diff # Fix NEON intrinsics usage ./003-fix-NEON-intrinsics.patch + ./remove-cubeb-vendor.patch ]; nativeBuildInputs = [ @@ -57,6 +56,7 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: { buildInputs = [ SDL2 cpuinfo + sources.cubeb curl libXrandr libbacktrace @@ -70,7 +70,7 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: { sources.soundtouch-patched sources.spirv-cross-patched wayland - ] ++ cubeb.passthru.backendLibs; + ]; cmakeFlags = [ (lib.cmakeBool "BUILD_TESTS" true) @@ -115,14 +115,11 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: { qtWrapperArgs = let - libPath = lib.makeLibraryPath ( - [ - sources.shaderc-patched - sources.spirv-cross-patched - vulkan-loader - ] - ++ cubeb.passthru.backendLibs - ); + libPath = lib.makeLibraryPath ([ + sources.shaderc-patched + sources.spirv-cross-patched + vulkan-loader + ]); in [ "--prefix LD_LIBRARY_PATH : ${libPath}" diff --git a/pkgs/by-name/du/duckstation/remove-cubeb-vendor.patch b/pkgs/by-name/du/duckstation/remove-cubeb-vendor.patch new file mode 100644 index 000000000000..b28d522cbd50 --- /dev/null +++ b/pkgs/by-name/du/duckstation/remove-cubeb-vendor.patch @@ -0,0 +1,29 @@ +diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt +index af35687..8347825 100644 +--- a/dep/CMakeLists.txt ++++ b/dep/CMakeLists.txt +@@ -22,9 +22,8 @@ add_subdirectory(rcheevos EXCLUDE_FROM_ALL) + disable_compiler_warnings_for_target(rcheevos) + add_subdirectory(rapidyaml EXCLUDE_FROM_ALL) + disable_compiler_warnings_for_target(rapidyaml) +-add_subdirectory(cubeb EXCLUDE_FROM_ALL) +-disable_compiler_warnings_for_target(cubeb) +-disable_compiler_warnings_for_target(speex) ++find_package(cubeb REQUIRED GLOBAL) ++add_library(cubeb ALIAS cubeb::cubeb) + add_subdirectory(kissfft EXCLUDE_FROM_ALL) + disable_compiler_warnings_for_target(kissfft) + +diff --git a/src/util/cubeb_audio_stream.cpp b/src/util/cubeb_audio_stream.cpp +index 85579c4..526d168 100644 +--- a/src/util/cubeb_audio_stream.cpp ++++ b/src/util/cubeb_audio_stream.cpp +@@ -261,7 +261,7 @@ std::vector> AudioStream::GetCubebDriverName + std::vector> names; + names.emplace_back(std::string(), TRANSLATE_STR("AudioStream", "Default")); + +- const char** cubeb_names = cubeb_get_backend_names(); ++ const char*const * cubeb_names = cubeb_get_backend_names(); + for (u32 i = 0; cubeb_names[i] != nullptr; i++) + names.emplace_back(cubeb_names[i], cubeb_names[i]); + return names; diff --git a/pkgs/by-name/du/duckstation/sources.nix b/pkgs/by-name/du/duckstation/sources.nix index 228bcbc2aaba..42a24ede16c5 100644 --- a/pkgs/by-name/du/duckstation/sources.nix +++ b/pkgs/by-name/du/duckstation/sources.nix @@ -9,6 +9,7 @@ stdenv, cmake, ninja, + cubeb, }: { @@ -163,4 +164,15 @@ platforms = lib.platforms.linux; }; }); + + cubeb = cubeb.overrideAttrs (old: { + pname = "cubeb-patched-for-duckstation"; + patches = (old.patches or [ ]) ++ [ + (fetchpatch { + url = "https://github.com/PCSX2/pcsx2/commit/430e31abe4a9e09567cb542f1416b011bb9b6ef9.patch"; + stripLen = 2; + hash = "sha256-bbH0c1X3lMeX6hfNKObhcq5xraFpicFV3mODQGYudvQ="; + }) + ]; + }); }