about summary refs log tree commit diff
path: root/pkgs/tools/audio/yabridge
diff options
context:
space:
mode:
authorKira Bruneau <kira.bruneau@pm.me>2022-07-06 09:56:07 -0400
committerKira Bruneau <kira.bruneau@pm.me>2022-07-11 12:30:26 -0400
commit5d9749589d7d6049e644b3dc9674d8f641b1684f (patch)
tree55e6c951e5f5f6e448d601ad8a322538a094ffaf /pkgs/tools/audio/yabridge
parent85deee6d6c8127d360096a5caa0aeb876b976496 (diff)
yabridge, yabridgectl: 3.8.1 → 4.0.0
Diffstat (limited to 'pkgs/tools/audio/yabridge')
-rw-r--r--pkgs/tools/audio/yabridge/default.nix64
-rw-r--r--pkgs/tools/audio/yabridge/hardcode-dependencies.patch54
-rw-r--r--pkgs/tools/audio/yabridge/libyabridge-from-nix-profiles.patch71
3 files changed, 136 insertions, 53 deletions
diff --git a/pkgs/tools/audio/yabridge/default.nix b/pkgs/tools/audio/yabridge/default.nix
index eb897f839a8fc..66cb4e6297827 100644
--- a/pkgs/tools/audio/yabridge/default.nix
+++ b/pkgs/tools/audio/yabridge/default.nix
@@ -8,17 +8,24 @@
 , ninja
 , pkg-config
 , wine
-, boost
 , libxcb
 , nix-update-script
 }:
 
 let
+  # Derived from subprojects/asio.wrap
+  asio = fetchFromGitHub {
+    owner = "chriskohlhoff";
+    repo = "asio";
+    rev = "asio-1-22-1";
+    sha256 = "sha256-UDLhx2yI6Txg0wP5H4oNIhgKIB2eMxUGCyT2x/7GgVg=";
+  };
+
   # Derived from subprojects/bitsery.wrap
   bitsery = fetchFromGitHub {
     owner = "fraillt";
     repo = "bitsery";
-    rev = "c0fc083c9de805e5825d7553507569febf6a6f93";
+    rev = "v5.2.2";
     sha256 = "sha256-VwzVtxt+E/SVcxqIJw8BKPO2q7bu/hkhY+nB7FHrZpY=";
   };
 
@@ -26,15 +33,23 @@ let
   function2 = fetchFromGitHub {
     owner = "Naios";
     repo = "function2";
-    rev = "02ca99831de59c7c3a4b834789260253cace0ced";
+    rev = "4.2.0";
     sha256 = "sha256-wrt+fCcM6YD4ZRZYvqqB+fNakCNmltdPZKlNkPLtgMs=";
   };
 
+  # Derived from subprojects/ghc_filesystem.wrap
+  ghc_filesystem = fetchFromGitHub {
+    owner = "gulrak";
+    repo = "filesystem";
+    rev = "v1.5.12";
+    sha256 = "sha256-j4RE5Ach7C7Kef4+H9AHSXa2L8OVyJljDwBduKcC4eE=";
+  };
+
   # Derived from subprojects/tomlplusplus.wrap
   tomlplusplus = fetchFromGitHub {
     owner = "marzer";
     repo = "tomlplusplus";
-    rev = "8e669aa6990e0ed219c169d491472d749f54c393";
+    rev = "v3.0.1";
     sha256 = "sha256-l8ckbCqjz3GUfwStcl3H2C+un5dZfT2uLtayvdu93D4=";
   };
 
@@ -42,29 +57,29 @@ let
   vst3 = fetchFromGitHub {
     owner = "robbert-vdh";
     repo = "vst3sdk";
-    rev = "v3.7.4_build_25-patched";
+    rev = "v3.7.5_build_44-patched";
     fetchSubmodules = true;
-    sha256 = "sha256-oHRJZItw+he5M+beVZkUrhJir6rgFZ80ORzA73mJT2A=";
+    sha256 = "sha256-6cuEUa+BXa6MnAYIBq873n0NRLadcPfMX+kpf4ysE6M=";
   };
 in multiStdenv.mkDerivation rec {
   pname = "yabridge";
-  version = "3.8.1";
+  version = "4.0.0";
 
   # NOTE: Also update yabridgectl's cargoHash when this is updated
   src = fetchFromGitHub {
     owner = "robbert-vdh";
     repo = pname;
     rev = version;
-    sha256 = "sha256-5Mi/aIjOKbn7guTj+AKGQRv+k7w4gzfdA9Mw4ocUlOE=";
+    sha256 = "sha256-L1YOeAYlq640CJZThW6euiOyrX0TeVbhZ3k/ZsmUC8I=";
   };
 
   # Unpack subproject sources
   postUnpack = ''(
     cd "$sourceRoot/subprojects"
+    cp -R --no-preserve=mode,ownership ${asio} asio
     cp -R --no-preserve=mode,ownership ${bitsery} bitsery
-    cp packagefiles/bitsery/* bitsery
     cp -R --no-preserve=mode,ownership ${function2} function2
-    cp packagefiles/function2/* function2
+    cp -R --no-preserve=mode,ownership ${ghc_filesystem} ghc_filesystem
     cp -R --no-preserve=mode,ownership ${tomlplusplus} tomlplusplus
     cp -R --no-preserve=mode,ownership ${vst3} vst3
   )'';
@@ -73,14 +88,23 @@ in multiStdenv.mkDerivation rec {
     # Hard code bitbridge & runtime dependencies
     (substituteAll {
       src = ./hardcode-dependencies.patch;
-      boost32 = pkgsi686Linux.boost;
       libxcb32 = pkgsi686Linux.xorg.libxcb;
       inherit libnotify wine;
     })
+
+    # Patch the chainloader to search for libyabridge through NIX_PROFILES
+    ./libyabridge-from-nix-profiles.patch
   ];
 
   postPatch = ''
     patchShebangs .
+    (
+      cd subprojects
+      cp packagefiles/asio/* asio
+      cp packagefiles/bitsery/* bitsery
+      cp packagefiles/function2/* function2
+      cp packagefiles/ghc_filesystem/* ghc_filesystem
+    )
   '';
 
   nativeBuildInputs = [
@@ -91,18 +115,12 @@ in multiStdenv.mkDerivation rec {
   ];
 
   buildInputs = [
-    boost
     libxcb
   ];
 
-  # Meson is no longer able to pick up Boost automatically.
-  # https://github.com/NixOS/nixpkgs/issues/86131
-  BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
-  BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
-
   mesonFlags = [
     "--cross-file" "cross-wine.conf"
-    "-Dwith-bitbridge=true"
+    "-Dbitbridge=true"
 
     # Requires CMake and is unnecessary
     "-Dtomlplusplus:generate_cmake_config=false"
@@ -111,10 +129,8 @@ in multiStdenv.mkDerivation rec {
   installPhase = ''
     runHook preInstall
     mkdir -p "$out/bin" "$out/lib"
-    cp yabridge-group*.exe{,.so} "$out/bin"
-    cp yabridge-host*.exe{,.so} "$out/bin"
-    cp libyabridge-vst2.so "$out/lib"
-    cp libyabridge-vst3.so "$out/lib"
+    cp yabridge-host{,-32}.exe{,.so} "$out/bin"
+    cp libyabridge{,-chainloader}-{vst2,vst3}.so "$out/lib"
     runHook postInstall
   '';
 
@@ -131,8 +147,8 @@ in multiStdenv.mkDerivation rec {
   };
 
   meta = with lib; {
-    description = "Yet Another VST bridge, run Windows VST2 plugins under Linux";
-    homepage = "https://github.com/robbert-vdh/yabridge";
+    description = "A modern and transparent way to use Windows VST2 and VST3 plugins on Linux";
+    homepage = src.meta.homepage;
     license = licenses.gpl3Plus;
     maintainers = with maintainers; [ kira-bruneau ];
     platforms = [ "x86_64-linux" ];
diff --git a/pkgs/tools/audio/yabridge/hardcode-dependencies.patch b/pkgs/tools/audio/yabridge/hardcode-dependencies.patch
index 16385db69e9a2..e695d9b7a2701 100644
--- a/pkgs/tools/audio/yabridge/hardcode-dependencies.patch
+++ b/pkgs/tools/audio/yabridge/hardcode-dependencies.patch
@@ -1,16 +1,8 @@
 diff --git a/meson.build b/meson.build
-index c71d4fdb..b3f381ba 100644
+index 8e1b8bfd..0696bfe6 100644
 --- a/meson.build
 +++ b/meson.build
-@@ -201,6 +201,7 @@ if with_32bit_libraries or with_bitbridge
-       'boost_filesystem',
-       static : with_static_boost,
-       dirs : [
-+        '@boost32@/lib',
-         # Used by Arch based distros
-         '/usr/local/lib32',
-         '/usr/lib32',
-@@ -224,7 +225,7 @@ if is_64bit_system
+@@ -186,7 +186,7 @@ if is_64bit_system
    xcb_64bit_dep = dependency('xcb')
  endif
  if with_32bit_libraries or with_bitbridge
@@ -19,25 +11,29 @@ index c71d4fdb..b3f381ba 100644
  endif
  
  # These are all headers-only libraries, and thus won't require separate 32-bit
+diff --git a/src/common/notifications.cpp b/src/common/notifications.cpp
+index da27a1bf..18482e06 100644
+--- a/src/common/notifications.cpp
++++ b/src/common/notifications.cpp
+@@ -49,7 +49,7 @@ bool send_notification(const std::string& title,
+         }
+     }
+ 
+-    Process process("notify-send");
++    Process process("@libnotify@/bin/notify-send");
+     process.arg("--urgency=normal");
+     process.arg("--app-name=yabridge");
+     process.arg(title);
 diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp
-index fc2c8b25..c73249e3 100644
+index ae2a7b43..5a0d61e1 100644
 --- a/src/plugin/utils.cpp
 +++ b/src/plugin/utils.cpp
-@@ -107,7 +107,7 @@ std::string PluginInfo::wine_version() const {
-         access(wineloader_path.c_str(), X_OK) == 0) {
-         wine_path = wineloader_path;
-     } else {
--        wine_path = bp::search_path("wine").string();
-+        wine_path = "@wine@/bin/wine";
-     }
- 
-     bp::ipstream output;
-@@ -436,7 +436,7 @@ Configuration load_config_for(const fs::path& yabridge_path) {
- bool send_notification(const std::string& title,
-                        const std::string body,
-                        bool append_origin) {
--    const fs::path notify_send_path = bp::search_path("notify-send");
-+    const fs::path notify_send_path = "@libnotify@/bin/notify-send";
-     if (notify_send_path.empty()) {
-         return false;
-     }
+@@ -93,7 +93,7 @@ std::string PluginInfo::wine_version() const {
+     // The '*.exe' scripts generated by winegcc allow you to override the binary
+     // used to run Wine, so will will handle this in the same way for our Wine
+     // version detection. We'll be using `execvpe`
+-    std::string wine_path = "wine";
++    std::string wine_path = "@wine@/bin/wine";
+     // NOLINTNEXTLINE(concurrency-mt-unsafe)
+     if (const char* wineloader_path = getenv("WINELOADER");
+         wineloader_path && access(wineloader_path, X_OK) == 0) {
diff --git a/pkgs/tools/audio/yabridge/libyabridge-from-nix-profiles.patch b/pkgs/tools/audio/yabridge/libyabridge-from-nix-profiles.patch
new file mode 100644
index 0000000000000..4d714d38fa20b
--- /dev/null
+++ b/pkgs/tools/audio/yabridge/libyabridge-from-nix-profiles.patch
@@ -0,0 +1,71 @@
+diff --git a/src/chainloader/utils.cpp b/src/chainloader/utils.cpp
+index ccd65d33..c7136b37 100644
+--- a/src/chainloader/utils.cpp
++++ b/src/chainloader/utils.cpp
+@@ -29,8 +29,10 @@
+ namespace fs = ghc::filesystem;
+ 
+ void* find_plugin_library(const std::string& name) {
++    Logger logger = Logger::create_exception_logger();
++
+     // Just using a goto for this would probably be cleaner, but yeah...
+-    const auto impl = [&name]() -> void* {
++    const auto impl = [&name, &logger]() -> void* {
+         // If `name` exists right next to the Wine plugin host binary, then
+         // we'll try loading that. Otherwise we'll fall back to regular
+         // `dlopen()` for distro packaged versions of yabridge
+@@ -52,27 +54,28 @@ void* find_plugin_library(const std::string& name) {
+             }
+         }
+ 
+-        if (void* handle = dlopen(name.c_str(), RTLD_LAZY | RTLD_LOCAL)) {
+-            return handle;
++        auto nix_profiles = getenv("NIX_PROFILES");
++        if (!nix_profiles || nix_profiles[0] == '\0') {
++            logger.log("");
++            logger.log("ERROR: 'NIX_PROFILES' environment variable is not set");
++            logger.log("");
++            return nullptr;
+         }
+ 
+-        // One last Hail Mary, in case ldconfig was not set up correctly. This
+-        // might be relevant for some of the `/usr/local/*` locations (although
+-        // you really, really shouldn't install yabridge there, please, thank
+-        // you). Yabridgectl searches through these same directories.
+-        for (const auto& lib_dir : {
+-                 "/usr/lib",
+-                 "/usr/lib/x86_64-linux-gnu",
+-                 "/usr/lib64",
+-                 "/usr/local/lib",
+-                 "/usr/local/lib/x86_64-linux-gnu",
+-                 "/usr/local/lib64",
+-             }) {
+-            const fs::path candidate = fs::path(lib_dir) / name;
+-            if (void* handle =
+-                    dlopen(candidate.c_str(), RTLD_LAZY | RTLD_LOCAL)) {
++        // NIX_PROFILES is iterated in reverse from the most specific (the
++        // user profile) to the least specific (the system profile).
++        const std::string_view nix_profiles_view = nix_profiles;
++        auto segment_end = nix_profiles_view.size();
++        while (segment_end != std::string::npos) {
++            const auto next_segment_end = nix_profiles_view.rfind(' ', segment_end - 1);
++            const auto segment_begin = next_segment_end + 1;
++            const auto profile = nix_profiles_view.substr(segment_begin, segment_end - segment_begin);
++            const auto candidate = fs::path(profile) / "lib" / name;
++            if (auto handle = dlopen(candidate.c_str(), RTLD_LAZY | RTLD_LOCAL)) {
+                 return handle;
+             }
++
++            segment_end = next_segment_end;
+         }
+ 
+         return nullptr;
+@@ -82,8 +85,6 @@ void* find_plugin_library(const std::string& name) {
+     if (!handle) {
+         const fs::path this_plugin_path = get_this_file_location();
+ 
+-        Logger logger = Logger::create_exception_logger();
+-
+         logger.log("");
+         logger.log("Could not find '" + name + "'");
+         logger.log("");