1 diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs
2 index d948beff..9b3f9ffb 100644
3 --- a/tools/yabridgectl/src/config.rs
4 +++ b/tools/yabridgectl/src/config.rs
5 @@ -22,6 +22,7 @@ use serde_derive::{Deserialize, Serialize};
6 use std::collections::{BTreeMap, BTreeSet, HashSet};
10 use std::path::{Path, PathBuf};
12 use xdg::BaseDirectories;
13 @@ -225,34 +226,27 @@ impl Config {
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-chainloader-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 + // NIX_PROFILES is iterated in reverse from the most specific (the user profile) to
24 + // the least specific (the system profile).
25 + let nix_profiles = env::var("NIX_PROFILES");
26 let user_path = xdg_dirs.get_data_home();
27 - let lib_directories = [
29 - // Used on Debian based distros
30 - Path::new("/usr/lib/x86_64-linux-gnu"),
32 - Path::new("/usr/lib64"),
33 - Path::new("/usr/local/lib"),
34 - Path::new("/usr/local/lib/x86_64-linux-gnu"),
35 - Path::new("/usr/local/lib64"),
38 + let lib_directories = nix_profiles.iter()
39 + .flat_map(|profiles| profiles.split(' ')
41 + .map(|profile| Path::new(profile).join("lib")))
42 + .chain(iter::once(user_path.clone()));
44 let mut candidates = lib_directories
46 .map(|directory| directory.join(VST2_CHAINLOADER_NAME));
48 match candidates.find(|directory| directory.exists()) {
49 Some(candidate) => candidate,
52 - "Could not find '{}' in either '{}' or '{}'. You can override the \
53 + "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \
54 default search path using 'yabridgectl set --path=<path>'.",
55 VST2_CHAINLOADER_NAME,
56 - system_path.display(),
60 diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs
61 index e66ef0da..bfe9c8bf 100644
62 --- a/tools/yabridgectl/src/main.rs
63 +++ b/tools/yabridgectl/src/main.rs
64 @@ -134,7 +134,7 @@ fn main() -> Result<()> {
66 "Path to the directory containing \
67 'libyabridge-chainloader-{clap,vst2,vst3}.so'. If this is not set, \
68 - then yabridgectl will look in both '/usr/lib' and \
69 + then yabridgectl will look through 'NIX_PROFILES' and \
70 '~/.local/share/yabridge' by default.",
72 .value_parser(parse_directory_path)