Merge pull request #108835 from MetaDark/yabridge

authored by

Sandro and committed by
GitHub
c340f37a bbfa0740

+226
+127
pkgs/tools/audio/yabridge/default.nix
···
··· 1 + { lib 2 + , stdenv 3 + , fetchFromGitHub 4 + , meson 5 + , ninja 6 + , pkg-config 7 + , wine 8 + , boost 9 + , libxcb 10 + }: 11 + 12 + let 13 + # Derived from subprojects/bitsery.wrap 14 + bitsery = rec { 15 + version = "5.2.0"; 16 + src = fetchFromGitHub { 17 + owner = "fraillt"; 18 + repo = "bitsery"; 19 + rev = "v${version}"; 20 + sha256 = "132b0n0xlpcv97l6bhk9n57hg95pkhwqzvr9jkv57nmggn76s5q7"; 21 + }; 22 + }; 23 + 24 + # Derived from subprojects/function2.wrap 25 + function2 = rec { 26 + version = "4.1.0"; 27 + src = fetchFromGitHub { 28 + owner = "Naios"; 29 + repo = "function2"; 30 + rev = version; 31 + sha256 = "0abrz2as62725g212qswi35nsdlf5wrhcz78hm2qidbgqr9rkir5"; 32 + }; 33 + }; 34 + 35 + # Derived from subprojects/tomlplusplus.wrap 36 + tomlplusplus = rec { 37 + version = "2.1.0"; 38 + src = fetchFromGitHub { 39 + owner = "marzer"; 40 + repo = "tomlplusplus"; 41 + rev = "v${version}"; 42 + sha256 = "0fspinnpyk1c9ay0h3wl8d4bbm6aswlypnrw2c7pk2i4mh981b4b"; 43 + }; 44 + }; 45 + 46 + # Derived from vst3.wrap 47 + vst3 = rec { 48 + version = "e2fbb41f28a4b311f2fc7d28e9b4330eec1802b6"; 49 + src = fetchFromGitHub { 50 + owner = "robbert-vdh"; 51 + repo = "vst3sdk"; 52 + rev = version; 53 + fetchSubmodules = true; 54 + sha256 = "1fqpylkbljifwdw2z75agc0yxnhmv4b09fxs3rvlw1qmm5mwx0p2"; 55 + }; 56 + }; 57 + in stdenv.mkDerivation rec { 58 + pname = "yabridge"; 59 + version = "3.0.0"; 60 + 61 + # NOTE: Also update yabridgectl's cargoSha256 when this is updated 62 + src = fetchFromGitHub { 63 + owner = "robbert-vdh"; 64 + repo = pname; 65 + rev = version; 66 + sha256 = "0ha7jhnkd2i49q5rz2hp7sq6hv19bir99x51hs6nvvcf16hlf2bp"; 67 + }; 68 + 69 + # Unpack subproject sources 70 + postUnpack = ''( 71 + cd "$sourceRoot/subprojects" 72 + cp -R --no-preserve=mode,ownership ${bitsery.src} bitsery-${bitsery.version} 73 + tar -xf bitsery-patch-${bitsery.version}.tar.xz 74 + cp -R --no-preserve=mode,ownership ${function2.src} function2-${function2.version} 75 + tar -xf function2-patch-${function2.version}.tar.xz 76 + cp -R --no-preserve=mode,ownership ${tomlplusplus.src} tomlplusplus 77 + cp -R --no-preserve=mode,ownership ${vst3.src} vst3 78 + )''; 79 + 80 + postPatch = '' 81 + patchShebangs . 82 + ''; 83 + 84 + nativeBuildInputs = [ 85 + meson 86 + ninja 87 + pkg-config 88 + wine 89 + ]; 90 + 91 + buildInputs = [ 92 + boost 93 + libxcb 94 + ]; 95 + 96 + # Meson is no longer able to pick up Boost automatically. 97 + # https://github.com/NixOS/nixpkgs/issues/86131 98 + BOOST_INCLUDEDIR = "${lib.getDev boost}/include"; 99 + BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; 100 + 101 + mesonFlags = [ 102 + "--cross-file" "cross-wine.conf" 103 + 104 + # Requires CMake and is unnecessary 105 + "-Dtomlplusplus:GENERATE_CMAKE_CONFIG=disabled" 106 + 107 + # tomlplusplus examples and tests don't build with winegcc 108 + "-Dtomlplusplus:BUILD_EXAMPLES=disabled" 109 + "-Dtomlplusplus:BUILD_TESTS=disabled" 110 + ]; 111 + 112 + installPhase = '' 113 + mkdir -p "$out/bin" "$out/lib" 114 + cp yabridge-group.exe{,.so} "$out/bin" 115 + cp yabridge-host.exe{,.so} "$out/bin" 116 + cp libyabridge-vst2.so "$out/lib" 117 + cp libyabridge-vst3.so "$out/lib" 118 + ''; 119 + 120 + meta = with lib; { 121 + description = "Yet Another VST bridge, run Windows VST2 plugins under Linux"; 122 + homepage = "https://github.com/robbert-vdh/yabridge"; 123 + license = licenses.gpl3Plus; 124 + maintainers = with maintainers; [ metadark ]; 125 + platforms = [ "x86_64-linux" ]; 126 + }; 127 + }
+23
pkgs/tools/audio/yabridgectl/default.nix
···
··· 1 + { lib, rustPlatform, yabridge }: 2 + 3 + rustPlatform.buildRustPackage rec { 4 + pname = "yabridgectl"; 5 + version = yabridge.version; 6 + 7 + src = yabridge.src; 8 + sourceRoot = "source/tools/yabridgectl"; 9 + cargoSha256 = "1sjhani8h7ap42yqlnj05sx59jyz2h12qlm1ibv8ldxcpwps0bwy"; 10 + 11 + patches = [ 12 + ./libyabridge-from-nix-profiles.patch 13 + ]; 14 + 15 + patchFlags = [ "-p3" ]; 16 + 17 + meta = with lib; { 18 + description = "A small, optional utility to help set up and update yabridge for several directories at once"; 19 + homepage = "https://github.com/robbert-vdh/yabridge/tree/master/tools/yabridgectl"; 20 + license = licenses.gpl3Plus; 21 + maintainers = with maintainers; [ metadark ]; 22 + }; 23 + }
+70
pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch
···
··· 1 + diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs 2 + index c1c89cf..d7bd822 100644 3 + --- a/tools/yabridgectl/src/config.rs 4 + +++ b/tools/yabridgectl/src/config.rs 5 + @@ -23,6 +23,7 @@ use std::collections::{BTreeMap, BTreeSet}; 6 + use std::env; 7 + use std::fmt::Display; 8 + use std::fs; 9 + +use std::iter; 10 + use std::path::{Path, PathBuf}; 11 + use which::which; 12 + use xdg::BaseDirectories; 13 + @@ -216,34 +217,24 @@ impl Config { 14 + } 15 + } 16 + None => { 17 + - // Search in the system library locations and in `~/.local/share/yabridge` if no 18 + - // path was set explicitely. We'll also search through `/usr/local/lib` just in case 19 + - // but since we advocate against installing yabridge there we won't list this path 20 + - // in the error message when `libyabridge-vst2.so` can't be found. 21 + - let system_path = Path::new("/usr/lib"); 22 + + // Search through NIX_PROFILES & data home directory if no path was set explicitly. 23 + + let nix_profiles = env::var("NIX_PROFILES"); 24 + let user_path = xdg_dirs.get_data_home(); 25 + - let lib_directories = [ 26 + - system_path, 27 + - // Used on Debian based distros 28 + - Path::new("/usr/lib/x86_64-linux-gnu"), 29 + - // Used on Fedora 30 + - Path::new("/usr/lib64"), 31 + - Path::new("/usr/local/lib"), 32 + - Path::new("/usr/local/lib/x86_64-linux-gnu"), 33 + - Path::new("/usr/local/lib64"), 34 + - &user_path, 35 + - ]; 36 + + let lib_directories = nix_profiles.iter() 37 + + .flat_map(|profiles| profiles.split(' ') 38 + + .map(|profile| Path::new(profile).join("lib"))) 39 + + .chain(iter::once(user_path.clone())); 40 + + 41 + let mut candidates = lib_directories 42 + - .iter() 43 + .map(|directory| directory.join(LIBYABRIDGE_VST2_NAME)); 44 + + 45 + match candidates.find(|directory| directory.exists()) { 46 + Some(candidate) => candidate, 47 + _ => { 48 + return Err(anyhow!( 49 + - "Could not find '{}' in either '{}' or '{}'. You can override the \ 50 + - default search path using 'yabridgectl set --path=<path>'.", 51 + + "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \ 52 + + default search path using 'yabridgectl set --path=<path>'.", 53 + LIBYABRIDGE_VST2_NAME, 54 + - system_path.display(), 55 + user_path.display() 56 + )); 57 + } 58 + diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs 59 + index 0db1bd4..221cdd0 100644 60 + --- a/tools/yabridgectl/src/main.rs 61 + +++ b/tools/yabridgectl/src/main.rs 62 + @@ -102,7 +102,7 @@ fn main() -> Result<()> { 63 + .about("Path to the directory containing 'libyabridge-{vst2,vst3}.so'") 64 + .long_about( 65 + "Path to the directory containing 'libyabridge-{vst2,vst3}.so'. If this \ 66 + - is not set, then yabridgectl will look in both '/usr/lib' and \ 67 + + is not set, then yabridgectl will look through 'NIX_PROFILES' and \ 68 + '~/.local/share/yabridge' by default.", 69 + ) 70 + .validator(validate_path)
+6
pkgs/top-level/all-packages.nix
··· 748 749 metapixel = callPackage ../tools/graphics/metapixel { }; 750 751 ### APPLICATIONS/TERMINAL-EMULATORS 752 753 alacritty = callPackage ../applications/terminal-emulators/alacritty {
··· 748 749 metapixel = callPackage ../tools/graphics/metapixel { }; 750 751 + yabridge = callPackage ../tools/audio/yabridge { 752 + wine = wineWowPackages.minimal; 753 + }; 754 + 755 + yabridgectl = callPackage ../tools/audio/yabridgectl { }; 756 + 757 ### APPLICATIONS/TERMINAL-EMULATORS 758 759 alacritty = callPackage ../applications/terminal-emulators/alacritty {