2021-02-17 17:02:09 +00:00
|
|
|
diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs
|
2024-01-13 08:15:51 +00:00
|
|
|
index da5f4ff5..c220d62d 100644
|
2021-02-17 17:02:09 +00:00
|
|
|
--- a/tools/yabridgectl/src/config.rs
|
|
|
|
+++ b/tools/yabridgectl/src/config.rs
|
2022-07-18 16:21:45 +00:00
|
|
|
@@ -22,6 +22,7 @@ use serde_derive::{Deserialize, Serialize};
|
|
|
|
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
2021-02-17 17:02:09 +00:00
|
|
|
use std::env;
|
|
|
|
use std::fs;
|
|
|
|
+use std::iter;
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use which::which;
|
|
|
|
use xdg::BaseDirectories;
|
2023-01-20 10:41:00 +00:00
|
|
|
@@ -225,34 +226,27 @@ impl Config {
|
2021-02-17 17:02:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
None => {
|
|
|
|
- // 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
|
2022-07-18 16:21:45 +00:00
|
|
|
- // in the error message when `libyabridge-chainloader-vst2.so` can't be found.
|
2021-02-17 17:02:09 +00:00
|
|
|
- let system_path = Path::new("/usr/lib");
|
|
|
|
+ // Search through NIX_PROFILES & data home directory if no path was set explicitly.
|
2022-02-10 20:34:41 +00:00
|
|
|
+ // NIX_PROFILES is iterated in reverse from the most specific (the user profile) to
|
|
|
|
+ // the least specific (the system profile).
|
2021-02-17 17:02:09 +00:00
|
|
|
+ let nix_profiles = env::var("NIX_PROFILES");
|
|
|
|
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(' ')
|
2022-02-10 20:34:41 +00:00
|
|
|
+ .rev()
|
2021-02-17 17:02:09 +00:00
|
|
|
+ .map(|profile| Path::new(profile).join("lib")))
|
|
|
|
+ .chain(iter::once(user_path.clone()));
|
|
|
|
+
|
|
|
|
let mut candidates = lib_directories
|
|
|
|
- .iter()
|
2022-07-18 16:21:45 +00:00
|
|
|
.map(|directory| directory.join(VST2_CHAINLOADER_NAME));
|
2021-02-17 17:02:09 +00:00
|
|
|
+
|
|
|
|
match candidates.find(|directory| directory.exists()) {
|
|
|
|
Some(candidate) => candidate,
|
|
|
|
_ => {
|
|
|
|
return Err(anyhow!(
|
|
|
|
- "Could not find '{}' in either '{}' or '{}'. You can override the \
|
|
|
|
+ "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \
|
2023-01-20 10:41:00 +00:00
|
|
|
default search path using 'yabridgectl set --path=<path>'.",
|
2022-07-18 16:21:45 +00:00
|
|
|
VST2_CHAINLOADER_NAME,
|
2021-02-17 17:02:09 +00:00
|
|
|
- system_path.display(),
|
|
|
|
user_path.display()
|
|
|
|
));
|
|
|
|
}
|
|
|
|
diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs
|
2024-01-13 08:15:51 +00:00
|
|
|
index 0a29d431..479eaef0 100644
|
2021-02-17 17:02:09 +00:00
|
|
|
--- a/tools/yabridgectl/src/main.rs
|
|
|
|
+++ b/tools/yabridgectl/src/main.rs
|
2024-01-13 08:15:51 +00:00
|
|
|
@@ -134,7 +134,7 @@ fn main() -> Result<()> {
|
2022-02-10 20:34:41 +00:00
|
|
|
.long_help(
|
2023-01-20 10:41:00 +00:00
|
|
|
"Path to the directory containing \
|
|
|
|
'libyabridge-chainloader-{clap,vst2,vst3}.so'. If this is not set, \
|
|
|
|
- then yabridgectl will look in both '/usr/lib' and \
|
|
|
|
+ then yabridgectl will look through 'NIX_PROFILES' and \
|
2021-02-17 17:02:09 +00:00
|
|
|
'~/.local/share/yabridge' by default.",
|
|
|
|
)
|
2024-01-13 08:15:51 +00:00
|
|
|
.value_parser(parse_directory_path)
|