Subject: [bug#63065] [PATCH v5 7/7] gnu: Add yabridgectl.

From: Sughosha <[email-masked]>
Date: Thu, 30 Nov 2023 11:57:28 +0100

* gnu/packages/audio.scm (yabridgectl): New variable.

Change-Id: If313e0209c7ecb2e9b0c020d254d790ba5b4bfb9
---
 gnu/packages/audio.scm | 60 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index f842548c93..0ba6914ddd 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -76,6 +76,7 @@ (define-module (gnu packages audio)
   #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cpp)
+  #:use-module (gnu packages crates-io)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages dbm)
   #:use-module (gnu packages documentation)
@@ -144,6 +145,7 @@ (define-module (gnu packages audio)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg)
+  #:use-module (guix build-system cargo)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system copy)
   #:use-module (guix build-system glib-or-gtk)
@@ -6029,6 +6031,64 @@ (define-public yabridge
 inter-plugin communication for VST2 plugins and quick startup times.")
     (license license:gpl3+)))
 
+(define-public yabridgectl
+  (package/inherit yabridge
+    (name "yabridgectl")
+    (build-system cargo-build-system)
+    (arguments
+     (list #:cargo-inputs
+           `(("rust-anyhow" ,rust-anyhow-1)
+             ("rust-clap" ,rust-clap-3)
+             ("rust-colored" ,rust-colored-2)
+             ("rust-is-executable" ,rust-is-executable-1)
+             ("rust-goblin" ,rust-goblin-0.6)
+             ("rust-libloading" ,rust-libloading-0.7)
+             ("rust-promptly" ,rust-promptly-0.3)
+             ("rust-rayon" ,rust-rayon-1)
+             ("rust-reflink" ,rust-reflink-0.1)
+             ("rust-serde" ,rust-serde-1)
+             ("rust-serde-derive" ,rust-serde-derive-1)
+             ("rust-serde-jsonrc" ,rust-serde-jsonrc-0.1)
+             ("rust-textwrap" ,rust-textwrap-0.11)
+             ("rust-toml" ,rust-toml-0.5)
+             ("rust-walkdir" ,rust-walkdir-2)
+             ("rust-which" ,rust-which-4)
+             ("rust-xdg" ,rust-xdg-2))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'change-directory
+                (lambda _
+                  (chdir "tools/yabridgectl")))
+               (add-after 'change-directory 'patch-paths
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (with-directory-excursion "src"
+                     (substitute* '("config.rs" "main.rs")
+                       (("/usr") (assoc-ref inputs "yabridge"))))))
+               (add-before 'configure 'patch-rust-reflink-version
+                 (lambda _
+                   (substitute* "Cargo.toml"
+                     (("reflink = .*$")
+                      (string-append "reflink = \""
+                                     #$(package-version rust-reflink-0.1)
+                                     "\"\n")))))
+               (add-after 'install 'wrap-program
+                (lambda* (#:key inputs #:allow-other-keys)
+                  (wrap-program (string-append #$output "/bin/yabridgectl")
+                    `("LD_LIBRARY_PATH" ":" prefix
+                      (,(string-append (assoc-ref inputs "yabridge") "/lib")
+                       ,(string-append (assoc-ref inputs "dbus") "/lib")))
+                    `("PATH" ":" prefix
+                      (,(string-append (assoc-ref inputs "yabridge")
+                                                         "/bin")))))))))
+    (native-inputs '())
+    (inputs
+     (list dbus))
+    (propagated-inputs
+     (list yabridge))
+    (synopsis "Utility to set up and update yabridge")
+    (description
+     "@command{yabridgectl} is a tool to setup and update @code{yabridge}.")))
+
 (define-public ableton-link
   (package
     (name "ableton-link")
-- 
2.41.0