From 9fce96e160094a1418ed8276d19df3f4df978de2 Mon Sep 17 00:00:00 2001 From: Kira Bruneau Date: Sat, 9 Jan 2021 02:15:41 -0500 Subject: [PATCH 1/4] yabridge: init at 2.2.1 --- pkgs/tools/audio/yabridge/default.nix | 112 ++++++++++++++++++ pkgs/tools/audio/yabridge/include-mutex.patch | 12 ++ pkgs/top-level/all-packages.nix | 4 + 3 files changed, 128 insertions(+) create mode 100644 pkgs/tools/audio/yabridge/default.nix create mode 100644 pkgs/tools/audio/yabridge/include-mutex.patch diff --git a/pkgs/tools/audio/yabridge/default.nix b/pkgs/tools/audio/yabridge/default.nix new file mode 100644 index 00000000000..0cea57aeb49 --- /dev/null +++ b/pkgs/tools/audio/yabridge/default.nix @@ -0,0 +1,112 @@ +{ lib +, stdenv +, fetchFromGitHub +, meson +, ninja +, pkg-config +, wine +, boost +, libxcb +}: + +let + # Derived from subprojects/bitsery.wrap + bitsery = rec { + version = "5.2.0"; + src = fetchFromGitHub { + owner = "fraillt"; + repo = "bitsery"; + rev = "v${version}"; + sha256 = "132b0n0xlpcv97l6bhk9n57hg95pkhwqzvr9jkv57nmggn76s5q7"; + }; + }; + + # Derived from subprojects/function2.wrap + function2 = rec { + version = "4.1.0"; + src = fetchFromGitHub { + owner = "Naios"; + repo = "function2"; + rev = version; + sha256 = "0abrz2as62725g212qswi35nsdlf5wrhcz78hm2qidbgqr9rkir5"; + }; + }; + + # Derived from subprojects/tomlplusplus.wrap + tomlplusplus = rec { + version = "2.1.0"; + src = fetchFromGitHub { + owner = "marzer"; + repo = "tomlplusplus"; + rev = "v${version}"; + sha256 = "0fspinnpyk1c9ay0h3wl8d4bbm6aswlypnrw2c7pk2i4mh981b4b"; + }; + }; +in stdenv.mkDerivation rec { + pname = "yabridge"; + version = "2.2.1"; + + src = fetchFromGitHub { + owner = "robbert-vdh"; + repo = pname; + rev = version; + sha256 = "0fg3r12hk8xm4698pbw9rjzcgrmibc2l3651pj96w0dzn6kyxi2g"; + }; + + # Unpack subproject sources + postUnpack = ''( + cd "$sourceRoot/subprojects" + cp -R --no-preserve=mode,ownership ${bitsery.src} bitsery-${bitsery.version} + tar -xf bitsery-patch-${bitsery.version}.tar.xz + cp -R --no-preserve=mode,ownership ${function2.src} function2-${function2.version} + tar -xf function2-patch-${function2.version}.tar.xz + cp -R --no-preserve=mode,ownership ${tomlplusplus.src} tomlplusplus + )''; + + patches = [ + ./include-mutex.patch + ]; + + nativeBuildInputs = [ + meson + ninja + pkg-config + wine + ]; + + 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" + + # Requires CMake and is unnecessary + "-Dtomlplusplus:GENERATE_CMAKE_CONFIG=disabled" + + # tomlplusplus examples and tests don't build with winegcc + "-Dtomlplusplus:BUILD_EXAMPLES=disabled" + "-Dtomlplusplus:BUILD_TESTS=disabled" + ]; + + installPhase = '' + mkdir -p "$out/bin" "$out/lib" + cp yabridge-group.exe{,.so} "$out/bin" + cp yabridge-host.exe{,.so} "$out/bin" + cp libyabridge.so "$out/lib" + ''; + + meta = with lib; { + description = "Yet Another VST bridge, run Windows VST2 plugins under Linux"; + homepage = "https://github.com/robbert-vdh/yabridge"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ metadark ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/pkgs/tools/audio/yabridge/include-mutex.patch b/pkgs/tools/audio/yabridge/include-mutex.patch new file mode 100644 index 00000000000..300e949b20d --- /dev/null +++ b/pkgs/tools/audio/yabridge/include-mutex.patch @@ -0,0 +1,12 @@ +diff --git a/src/common/communication.h b/src/common/communication.h +index 968ac1e..f3a8453 100644 +--- a/src/common/communication.h ++++ b/src/common/communication.h +@@ -17,6 +17,7 @@ + #pragma once + + #include ++#include + + #include + #include diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d0a3c3dee8d..a68bc936901 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -748,6 +748,10 @@ in metapixel = callPackage ../tools/graphics/metapixel { }; + yabridge = callPackage ../tools/audio/yabridge { + wine = wineWowPackages.minimal; + }; + ### APPLICATIONS/TERMINAL-EMULATORS alacritty = callPackage ../applications/terminal-emulators/alacritty { From e3d0774d0b85db741b435c1e1474d63854533235 Mon Sep 17 00:00:00 2001 From: Kira Bruneau Date: Sat, 9 Jan 2021 02:15:57 -0500 Subject: [PATCH 2/4] yabridgectl: init at 2.2.1 --- pkgs/tools/audio/yabridge/default.nix | 1 + pkgs/tools/audio/yabridgectl/default.nix | 23 +++++++ .../libyabridge-from-nix-profiles.patch | 64 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 90 insertions(+) create mode 100644 pkgs/tools/audio/yabridgectl/default.nix create mode 100644 pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch diff --git a/pkgs/tools/audio/yabridge/default.nix b/pkgs/tools/audio/yabridge/default.nix index 0cea57aeb49..500117442fb 100644 --- a/pkgs/tools/audio/yabridge/default.nix +++ b/pkgs/tools/audio/yabridge/default.nix @@ -46,6 +46,7 @@ in stdenv.mkDerivation rec { pname = "yabridge"; version = "2.2.1"; + # NOTE: Also update yabridgectl's cargoSha256 when this is updated src = fetchFromGitHub { owner = "robbert-vdh"; repo = pname; diff --git a/pkgs/tools/audio/yabridgectl/default.nix b/pkgs/tools/audio/yabridgectl/default.nix new file mode 100644 index 00000000000..4b90525e56e --- /dev/null +++ b/pkgs/tools/audio/yabridgectl/default.nix @@ -0,0 +1,23 @@ +{ lib, rustPlatform, yabridge }: + +rustPlatform.buildRustPackage rec { + pname = "yabridgectl"; + version = yabridge.version; + + src = yabridge.src; + sourceRoot = "source/tools/yabridgectl"; + cargoSha256 = "08j865n9vjnkc1g33lnzlj2nr3raj3av9cnvdqbkh65kr4zs4r9h"; + + patches = [ + ./libyabridge-from-nix-profiles.patch + ]; + + patchFlags = [ "-p3" ]; + + meta = with lib; { + description = "A small, optional utility to help set up and update yabridge for several directories at once"; + homepage = "https://github.com/robbert-vdh/yabridge/tree/master/tools/yabridgectl"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ metadark ]; + }; +} diff --git a/pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch b/pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch new file mode 100644 index 00000000000..0b8fb4eacb3 --- /dev/null +++ b/pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch @@ -0,0 +1,64 @@ +diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs +index fbb6b97..5499b6c 100644 +--- a/tools/yabridgectl/src/config.rs ++++ b/tools/yabridgectl/src/config.rs +@@ -20,8 +20,10 @@ use anyhow::{anyhow, Context, Result}; + use rayon::prelude::*; + use serde_derive::{Deserialize, Serialize}; + use std::collections::{BTreeMap, BTreeSet}; ++use std::env; + use std::fmt::Display; + use std::fs; ++use std::iter; + use std::path::{Path, PathBuf}; + use which::which; + use xdg::BaseDirectories; +@@ -176,14 +178,15 @@ impl Config { + } + } + None => { +- // Search in the two common installation locations if no path was set explicitely. +- // We'll also search through `/usr/local/lib` just in case but since we advocate +- // against isntalling yabridge there we won't list this path in the error message +- // when `libyabridge.so` can't be found. +- let system_path = Path::new("/usr/lib"); +- let system_path_alt = Path::new("/usr/local/lib"); ++ // Search through NIX_PROFILES & data home directory if no path was set explicitly. ++ let nix_profiles = env::var("NIX_PROFILES"); + let user_path = yabridge_directories()?.get_data_home(); +- for directory in &[system_path, system_path_alt, &user_path] { ++ let lib_directories = nix_profiles.iter() ++ .flat_map(|profiles| profiles.split(' ') ++ .map(|profile| Path::new(profile).join("lib"))) ++ .chain(iter::once(user_path.clone())); ++ ++ for directory in lib_directories { + let candidate = directory.join(LIBYABRIDGE_NAME); + if candidate.exists() { + return Ok(candidate); +@@ -191,10 +194,9 @@ impl Config { + } + + Err(anyhow!( +- "Could not find '{}' in either '{}' or '{}'. You can override the default \ +- search path using 'yabridgectl set --path='.", ++ "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \ ++ default search path using 'yabridgectl set --path='.", + LIBYABRIDGE_NAME, +- system_path.display(), + user_path.display() + )) + } +diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs +index 649ce4e..0f1f0e7 100644 +--- a/tools/yabridgectl/src/main.rs ++++ b/tools/yabridgectl/src/main.rs +@@ -102,7 +102,7 @@ fn main() -> Result<()> { + .about("Path to the directory containing 'libyabridge.so'") + .long_about( + "Path to the directory containing 'libyabridge.so'. If this is \ +- not set, then yabridgectl will look in both '/usr/lib' and \ ++ not set, then yabridgectl will look through 'NIX_PROFILES' and \ + '~/.local/share/yabridge' by default.", + ) + .validator(validate_path) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a68bc936901..b356384f88d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -752,6 +752,8 @@ in wine = wineWowPackages.minimal; }; + yabridgectl = callPackage ../tools/audio/yabridgectl { }; + ### APPLICATIONS/TERMINAL-EMULATORS alacritty = callPackage ../applications/terminal-emulators/alacritty { From 26a970df503cab8bd27dbdc06a89b167178ec4b4 Mon Sep 17 00:00:00 2001 From: Kira Bruneau Date: Sun, 14 Feb 2021 12:41:07 -0500 Subject: [PATCH 3/4] yabridge: 2.2.1 -> 3.0.0 --- pkgs/tools/audio/yabridge/default.nix | 26 ++++++++++++++----- pkgs/tools/audio/yabridge/include-mutex.patch | 12 --------- 2 files changed, 20 insertions(+), 18 deletions(-) delete mode 100644 pkgs/tools/audio/yabridge/include-mutex.patch diff --git a/pkgs/tools/audio/yabridge/default.nix b/pkgs/tools/audio/yabridge/default.nix index 500117442fb..56f6cddb61e 100644 --- a/pkgs/tools/audio/yabridge/default.nix +++ b/pkgs/tools/audio/yabridge/default.nix @@ -42,16 +42,28 @@ let sha256 = "0fspinnpyk1c9ay0h3wl8d4bbm6aswlypnrw2c7pk2i4mh981b4b"; }; }; + + # Derived from vst3.wrap + vst3 = rec { + version = "e2fbb41f28a4b311f2fc7d28e9b4330eec1802b6"; + src = fetchFromGitHub { + owner = "robbert-vdh"; + repo = "vst3sdk"; + rev = version; + fetchSubmodules = true; + sha256 = "1fqpylkbljifwdw2z75agc0yxnhmv4b09fxs3rvlw1qmm5mwx0p2"; + }; + }; in stdenv.mkDerivation rec { pname = "yabridge"; - version = "2.2.1"; + version = "3.0.0"; # NOTE: Also update yabridgectl's cargoSha256 when this is updated src = fetchFromGitHub { owner = "robbert-vdh"; repo = pname; rev = version; - sha256 = "0fg3r12hk8xm4698pbw9rjzcgrmibc2l3651pj96w0dzn6kyxi2g"; + sha256 = "0ha7jhnkd2i49q5rz2hp7sq6hv19bir99x51hs6nvvcf16hlf2bp"; }; # Unpack subproject sources @@ -62,11 +74,12 @@ in stdenv.mkDerivation rec { cp -R --no-preserve=mode,ownership ${function2.src} function2-${function2.version} tar -xf function2-patch-${function2.version}.tar.xz cp -R --no-preserve=mode,ownership ${tomlplusplus.src} tomlplusplus + cp -R --no-preserve=mode,ownership ${vst3.src} vst3 )''; - patches = [ - ./include-mutex.patch - ]; + postPatch = '' + patchShebangs . + ''; nativeBuildInputs = [ meson @@ -100,7 +113,8 @@ in stdenv.mkDerivation rec { mkdir -p "$out/bin" "$out/lib" cp yabridge-group.exe{,.so} "$out/bin" cp yabridge-host.exe{,.so} "$out/bin" - cp libyabridge.so "$out/lib" + cp libyabridge-vst2.so "$out/lib" + cp libyabridge-vst3.so "$out/lib" ''; meta = with lib; { diff --git a/pkgs/tools/audio/yabridge/include-mutex.patch b/pkgs/tools/audio/yabridge/include-mutex.patch deleted file mode 100644 index 300e949b20d..00000000000 --- a/pkgs/tools/audio/yabridge/include-mutex.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/src/common/communication.h b/src/common/communication.h -index 968ac1e..f3a8453 100644 ---- a/src/common/communication.h -+++ b/src/common/communication.h -@@ -17,6 +17,7 @@ - #pragma once - - #include -+#include - - #include - #include From ebbb927beefefdbd2b1f0d7b7893244163731cc6 Mon Sep 17 00:00:00 2001 From: Kira Bruneau Date: Sun, 14 Feb 2021 13:03:37 -0500 Subject: [PATCH 4/4] yabridgectl: 2.2.1 -> 3.0.0 --- pkgs/tools/audio/yabridgectl/default.nix | 2 +- .../libyabridge-from-nix-profiles.patch | 78 ++++++++++--------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/pkgs/tools/audio/yabridgectl/default.nix b/pkgs/tools/audio/yabridgectl/default.nix index 4b90525e56e..6fa85cd89e8 100644 --- a/pkgs/tools/audio/yabridgectl/default.nix +++ b/pkgs/tools/audio/yabridgectl/default.nix @@ -6,7 +6,7 @@ rustPlatform.buildRustPackage rec { src = yabridge.src; sourceRoot = "source/tools/yabridgectl"; - cargoSha256 = "08j865n9vjnkc1g33lnzlj2nr3raj3av9cnvdqbkh65kr4zs4r9h"; + cargoSha256 = "1sjhani8h7ap42yqlnj05sx59jyz2h12qlm1ibv8ldxcpwps0bwy"; patches = [ ./libyabridge-from-nix-profiles.patch diff --git a/pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch b/pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch index 0b8fb4eacb3..e17cda6ada3 100644 --- a/pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch +++ b/pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch @@ -1,64 +1,70 @@ diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs -index fbb6b97..5499b6c 100644 +index c1c89cf..d7bd822 100644 --- a/tools/yabridgectl/src/config.rs +++ b/tools/yabridgectl/src/config.rs -@@ -20,8 +20,10 @@ use anyhow::{anyhow, Context, Result}; - use rayon::prelude::*; - use serde_derive::{Deserialize, Serialize}; - use std::collections::{BTreeMap, BTreeSet}; -+use std::env; +@@ -23,6 +23,7 @@ use std::collections::{BTreeMap, BTreeSet}; + use std::env; use std::fmt::Display; use std::fs; +use std::iter; use std::path::{Path, PathBuf}; use which::which; use xdg::BaseDirectories; -@@ -176,14 +178,15 @@ impl Config { +@@ -216,34 +217,24 @@ impl Config { } } None => { -- // Search in the two common installation locations if no path was set explicitely. -- // We'll also search through `/usr/local/lib` just in case but since we advocate -- // against isntalling yabridge there we won't list this path in the error message -- // when `libyabridge.so` can't be found. +- // Search in the system library locations and in `~/.local/share/yabridge` if no +- // path was set explicitely. We'll also search through `/usr/local/lib` just in case +- // but since we advocate against installing yabridge there we won't list this path +- // in the error message when `libyabridge-vst2.so` can't be found. - let system_path = Path::new("/usr/lib"); -- let system_path_alt = Path::new("/usr/local/lib"); + // Search through NIX_PROFILES & data home directory if no path was set explicitly. + let nix_profiles = env::var("NIX_PROFILES"); - let user_path = yabridge_directories()?.get_data_home(); -- for directory in &[system_path, system_path_alt, &user_path] { + let user_path = xdg_dirs.get_data_home(); +- let lib_directories = [ +- system_path, +- // Used on Debian based distros +- Path::new("/usr/lib/x86_64-linux-gnu"), +- // Used on Fedora +- Path::new("/usr/lib64"), +- Path::new("/usr/local/lib"), +- Path::new("/usr/local/lib/x86_64-linux-gnu"), +- Path::new("/usr/local/lib64"), +- &user_path, +- ]; + let lib_directories = nix_profiles.iter() + .flat_map(|profiles| profiles.split(' ') + .map(|profile| Path::new(profile).join("lib"))) + .chain(iter::once(user_path.clone())); + -+ for directory in lib_directories { - let candidate = directory.join(LIBYABRIDGE_NAME); - if candidate.exists() { - return Ok(candidate); -@@ -191,10 +194,9 @@ impl Config { - } - - Err(anyhow!( -- "Could not find '{}' in either '{}' or '{}'. You can override the default \ -- search path using 'yabridgectl set --path='.", -+ "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \ -+ default search path using 'yabridgectl set --path='.", - LIBYABRIDGE_NAME, -- system_path.display(), - user_path.display() - )) - } + let mut candidates = lib_directories +- .iter() + .map(|directory| directory.join(LIBYABRIDGE_VST2_NAME)); ++ + match candidates.find(|directory| directory.exists()) { + Some(candidate) => candidate, + _ => { + return Err(anyhow!( +- "Could not find '{}' in either '{}' or '{}'. You can override the \ +- default search path using 'yabridgectl set --path='.", ++ "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \ ++ default search path using 'yabridgectl set --path='.", + LIBYABRIDGE_VST2_NAME, +- system_path.display(), + user_path.display() + )); + } diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs -index 649ce4e..0f1f0e7 100644 +index 0db1bd4..221cdd0 100644 --- a/tools/yabridgectl/src/main.rs +++ b/tools/yabridgectl/src/main.rs @@ -102,7 +102,7 @@ fn main() -> Result<()> { - .about("Path to the directory containing 'libyabridge.so'") + .about("Path to the directory containing 'libyabridge-{vst2,vst3}.so'") .long_about( - "Path to the directory containing 'libyabridge.so'. If this is \ -- not set, then yabridgectl will look in both '/usr/lib' and \ -+ not set, then yabridgectl will look through 'NIX_PROFILES' and \ + "Path to the directory containing 'libyabridge-{vst2,vst3}.so'. If this \ +- is not set, then yabridgectl will look in both '/usr/lib' and \ ++ is not set, then yabridgectl will look through 'NIX_PROFILES' and \ '~/.local/share/yabridge' by default.", ) .validator(validate_path)