nixpkgs/pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch

71 lines
3.6 KiB
Diff
Raw Normal View History

2021-01-09 07:15:57 +00:00
diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs
2021-04-17 15:46:53 +00:00
index 6e05e34..656eef3 100644
2021-01-09 07:15:57 +00:00
--- a/tools/yabridgectl/src/config.rs
+++ b/tools/yabridgectl/src/config.rs
2021-04-17 15:46:53 +00:00
@@ -23,6 +23,7 @@ use std::collections::{BTreeMap, BTreeSet, HashSet};
2021-02-14 18:03:37 +00:00
use std::env;
2021-01-09 07:15:57 +00:00
use std::fmt::Display;
use std::fs;
+use std::iter;
use std::path::{Path, PathBuf};
use which::which;
use xdg::BaseDirectories;
2021-04-17 15:46:53 +00:00
@@ -222,34 +223,24 @@ impl Config {
2021-01-09 07:15:57 +00:00
}
}
None => {
2021-02-14 18:03:37 +00:00
- // 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.
2021-01-09 07:15:57 +00:00
- let system_path = Path::new("/usr/lib");
+ // Search through NIX_PROFILES & data home directory if no path was set explicitly.
+ let nix_profiles = env::var("NIX_PROFILES");
2021-02-14 18:03:37 +00:00
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,
- ];
2021-01-09 07:15:57 +00:00
+ let lib_directories = nix_profiles.iter()
+ .flat_map(|profiles| profiles.split(' ')
+ .map(|profile| Path::new(profile).join("lib")))
+ .chain(iter::once(user_path.clone()));
+
2021-02-14 18:03:37 +00:00
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=<path>'.",
+ "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \
+ default search path using 'yabridgectl set --path=<path>'.",
LIBYABRIDGE_VST2_NAME,
- system_path.display(),
user_path.display()
));
}
2021-01-09 07:15:57 +00:00
diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs
2021-04-17 15:46:53 +00:00
index ce701b8..b6b9633 100644
2021-01-09 07:15:57 +00:00
--- a/tools/yabridgectl/src/main.rs
+++ b/tools/yabridgectl/src/main.rs
2021-04-17 15:46:53 +00:00
@@ -150,7 +150,7 @@ fn main() -> Result<()> {
2021-02-14 18:03:37 +00:00
.about("Path to the directory containing 'libyabridge-{vst2,vst3}.so'")
2021-01-09 07:15:57 +00:00
.long_about(
2021-02-14 18:03:37 +00:00
"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 \
2021-01-09 07:15:57 +00:00
'~/.local/share/yabridge' by default.",
)
.validator(validate_path)