summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorKira Bruneau <kira.bruneau@gmail.com>2021-01-09 02:15:57 -0500
committerKira Bruneau <kira.bruneau@gmail.com>2021-02-14 19:44:17 -0500
commite3d0774d0b85db741b435c1e1474d63854533235 (patch)
treecb9ecabe2d8ebba7996827a1f6c91b967592eea7 /pkgs
parent9fce96e160094a1418ed8276d19df3f4df978de2 (diff)
downloadnixpkgs-e3d0774d0b85db741b435c1e1474d63854533235.tar
nixpkgs-e3d0774d0b85db741b435c1e1474d63854533235.tar.gz
nixpkgs-e3d0774d0b85db741b435c1e1474d63854533235.tar.bz2
nixpkgs-e3d0774d0b85db741b435c1e1474d63854533235.tar.lz
nixpkgs-e3d0774d0b85db741b435c1e1474d63854533235.tar.xz
nixpkgs-e3d0774d0b85db741b435c1e1474d63854533235.tar.zst
nixpkgs-e3d0774d0b85db741b435c1e1474d63854533235.zip
yabridgectl: init at 2.2.1
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/tools/audio/yabridge/default.nix1
-rw-r--r--pkgs/tools/audio/yabridgectl/default.nix23
-rw-r--r--pkgs/tools/audio/yabridgectl/libyabridge-from-nix-profiles.patch64
-rw-r--r--pkgs/top-level/all-packages.nix2
4 files changed, 90 insertions, 0 deletions
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=<path>'.",
++                    "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \
++                     default search path using 'yabridgectl set --path=<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 {