Subject: [bug#74432] [rust-team 9/9] gnu: rust-apps: Add blue-recorder

From: Divya Ranjan <[email-masked]>
Date: Tue, 19 Nov 2024 07:32:17 +0000

* gnu/packages/rust-apps.scm (blue-recorder): New variable

Change-Id: Ic282f69fa2b5b4ffce938d106961c4df5e491cd3
---
 gnu/packages/rust-apps.scm | 90 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 89 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm
index 303fe44995..3f4e78a59c 100644
--- a/gnu/packages/rust-apps.scm
+++ b/gnu/packages/rust-apps.scm
@@ -106,7 +106,10 @@ (define-module (gnu packages rust-apps)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages webkit)
-  #:use-module (gnu packages xorg))
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages gstreamer)
+  #:use-module (gnu packages gettext)
+  #:use-module (gnu packages video))
 
 (define-public aardvark-dns
   (package
@@ -3889,3 +3892,88 @@ (define-public htmlq
     (synopsis "Like jq, but for HTML")
     (description "Extract content from HTML files using CSS selectors.")
     (license license:expat)))
+
+(define-public blue-recorder
+  (package
+    (name "blue-recorder")
+    (version "0.2.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/xlmnxp/blue-recorder")
+             (commit "1cfa3bbb1b5ea845b3e4c51eba269745f0c3e271")))
+       ;; The original Cargo.toml tries to pull gdk from git, which is impossible
+       ;; during guix build.
+       (snippet #~(begin
+                    (use-modules (guix build utils))
+                    (substitute* "Cargo.toml"
+                      (("gdk = \\{ git =.+")
+                       "gdk = { version = \"0.7.3\", package = \"gdk4\" }
+"))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0fz5l1z5rq8gx2vhrpfnf5l5karlqa7m8fdwx7ixlvy5klywwa5y"))))
+    (build-system cargo-build-system)
+    (arguments
+     `(#:cargo-build-flags '("--release")
+       #:phases ,#~(modify-phases %standard-phases
+                     ;; As per the application’s build instructions the binary
+                     ;; needs to be wrapped with po and data paths as environment
+                     ;; variables.
+                     (add-after 'install 'wrap-paths
+                       (lambda _
+                         (let* ((bin (string-append #$output "/bin"))
+                                (name-version (string-append #$name "-"
+                                                             #$version))
+                                (blue-recorder (string-append bin
+                                                "/blue-recorder"))
+                                (src (string-append #$output
+                                                    "/share/cargo/src/"))
+                                (po (string-append src name-version "/po/"))
+                                (data (string-append src name-version "/data/")))
+                           (wrap-program blue-recorder
+                             `("PO_DIR" prefix
+                               (,po))
+                             `("DATA_DIR" prefix
+                               (,data)))))))
+       #:cargo-inputs (("rust-async-std" ,rust-async-std-1)
+                       ("rust-chrono" ,rust-chrono-0.4)
+                       ("rust-dark-light" ,rust-dark-light-1)
+                       ("rust-dirs" ,rust-dirs-4)
+                       ("rust-filename" ,rust-filename-0.1)
+                       ("rust-gdk-pixbuf" ,rust-gdk-pixbuf-0.9)
+                       ("rust-gdk4" ,rust-gdk4-0.7)
+                       ("rust-gettext-rs" ,rust-gettext-rs-0.7)
+                       ("rust-gio" ,rust-gio-0.15)
+                       ("rust-glib" ,rust-glib-0.10)
+                       ("rust-gstreamer" ,rust-gstreamer-0.21)
+                       ("rust-gtk-sys" ,rust-gtk-sys-0.18)
+                       ("rust-gtk4" ,rust-gtk4-0.8)
+                       ("rust-regex" ,rust-regex-1)
+                       ("rust-rust-ini" ,rust-rust-ini-0.18)
+                       ("rust-secfmt" ,rust-secfmt-0.1)
+                       ("rust-subprocess" ,rust-subprocess-0.2)
+                       ("rust-tempfile" ,rust-tempfile-3)
+                       ("rust-zbus" ,rust-zbus-3))))
+    (native-inputs (list pkg-config
+                         glib
+                         graphene
+                         gstreamer
+                         gnu-gettext
+                         libappindicator
+                         xz))
+    (inputs (list glib bash-minimal))
+    (propagated-inputs (list ffmpeg
+                             gtk
+                             gtk+
+                             xwininfo
+                             libappindicator
+                             pulseaudio))
+    (home-page "https://github.com/xlmnxp/blue-recorder/")
+    (synopsis "Simple Screen Recorder written in Rust based on Green Recorder")
+    (description
+     "A simple desktop recorder for Linux systems.
+Built using GTK4 and ffmpeg.  It supports recording audio and video on almost all Linux
+interfaces with support for Wayland display server on GNOME session.")
+    (license license:gpl3)))
-- 
2.46.0