[PATCH] gnu: Add rust-speakersafetyd-1.

  • Open
  • quality assurance status badge
Details
2 participants
  • Nicolas Graves
  • Roman Scherer
Owner
unassigned
Submitted by
Roman Scherer
Severity
normal
R
R
Roman Scherer wrote on 30 Oct 20:41 +0100
(address . guix-patches@gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)
730badd0c62c83b9c779ee2ad9c9ca41af34bfd9.1730317218.git.roman@burningswell.com
* gnu/packages/crates-io.scm (rust-speakersafetyd-1): New variable.

Change-Id: I02eb6e0c23fd04cff86b67ed30e8867af07a724b
---
gnu/packages/crates-io.scm | 55 ++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)

Toggle diff (70 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index c08ccd29fd..83b543f552 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -73271,6 +73271,61 @@ (define-public rust-sourcemap-6
(description "This package provides basic sourcemap handling for Rust.")
(license license:bsd-3)))
+(define-public rust-speakersafetyd-1
+ (package
+ (name "rust-speakersafetyd")
+ (version "1.0.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "speakersafetyd" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "1dvyj194niz5i4rldsqvjmz8j7df9w9qpvf9rwg3vsnzc2mjh0zg"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs (("rust-alsa" ,rust-alsa-0.8)
+ ("rust-chrono" ,rust-chrono-0.4)
+ ("rust-clap" ,rust-clap-4)
+ ("rust-clap-verbosity-flag" ,rust-clap-verbosity-flag-2)
+ ("rust-configparser" ,rust-configparser-3)
+ ("rust-json" ,rust-json-0.12)
+ ("rust-libc" ,rust-libc-0.2)
+ ("rust-log" ,rust-log-0.4)
+ ("rust-signal-hook" ,rust-signal-hook-0.3)
+ ("rust-simple-logger" ,rust-simple-logger-1))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'fix-paths
+ (lambda* (#:key outputs #:allow-other-keys)
+ (substitute* "src/main.rs"
+ (("share/speakersafetyd") "share")
+ (("/usr/local") (assoc-ref outputs "out")))))
+ (add-after 'unpack 'remove-systemd-udev-rules
+ (lambda _
+ (substitute* "95-speakersafetyd.rules"
+ ((".*SYSTEMD_WANTS.*") ""))))
+ (add-after 'install 'install-conf
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((target (string-append (assoc-ref outputs "out") "/share")))
+ (copy-recursively "conf" target))))
+ (add-after 'install 'install-udev-rules
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (mkdir-p (string-append out "/lib/udev/rules.d"))
+ (copy-file "95-speakersafetyd.rules"
+ (string-append out
+ "/lib/udev/rules.d/"
+ "95-speakersafetyd.rules"))))))))
+ (inputs (list alsa-lib))
+ (native-inputs (list pkg-config))
+ (home-page "https://github.com/AsahiLinux/speakersafetyd/")
+ (synopsis "Speaker protection daemon")
+ (description "Speakersafetyd is a userspace daemon written in Rust that
+implements an analogue of the Texas Instruments Smart Amp speaker protection
+model.")
+ (license license:expat)))
+
(define-public rust-special-0.8
(package
(name "rust-special")

base-commit: d6f775c30c6f47e174f6110d1089edc6315600e4
--
2.46.0
N
N
Nicolas Graves wrote on 3 Nov 21:44 +0100
tag 74120 easy
(address . control@debbugs.gnu.org)
87v7x4m4ie.fsf@ngraves.fr
tags 74120 + easy
quit

--
Best regards,
Nicolas Graves
N
N
Nicolas Graves wrote on 3 Nov 21:48 +0100
Re: [bug#74120] [PATCH] gnu: Add rust-speakersafetyd-1.
87cyjcxcv8.fsf@ngraves.fr
Hi Roman,

Just so you know, you can probably use gexpressions for the phases, this
would make it easier to read.

Can you resend a revised patch? Thanks!

--
Best regards,
Nicolas Graves
R
R
Roman Scherer wrote on 6 Nov 18:08 +0100
[PATCH v2] gnu: Add rust-speakersafetyd-1.
(address . 74120@debbugs.gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)
b1cad06d9c0f23aa5f6d6cffc3e6e26375a38f60.1730912852.git.roman@burningswell.com
* gnu/packages/crates-io.scm (rust-speakersafetyd-1): New variable.

Change-Id: I02eb6e0c23fd04cff86b67ed30e8867af07a724b
---
gnu/packages/crates-io.scm | 52 ++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)

Toggle diff (67 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index c08ccd29fd..22b28e0845 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -73271,6 +73271,58 @@ (define-public rust-sourcemap-6
(description "This package provides basic sourcemap handling for Rust.")
(license license:bsd-3)))
+(define-public rust-speakersafetyd-1
+ (package
+ (name "rust-speakersafetyd")
+ (version "1.0.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "speakersafetyd" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "1dvyj194niz5i4rldsqvjmz8j7df9w9qpvf9rwg3vsnzc2mjh0zg"))))
+ (build-system cargo-build-system)
+ (arguments
+ (list
+ #:cargo-inputs `(("rust-alsa" ,rust-alsa-0.8)
+ ("rust-chrono" ,rust-chrono-0.4)
+ ("rust-clap" ,rust-clap-4)
+ ("rust-clap-verbosity-flag" ,rust-clap-verbosity-flag-2)
+ ("rust-configparser" ,rust-configparser-3)
+ ("rust-json" ,rust-json-0.12)
+ ("rust-libc" ,rust-libc-0.2)
+ ("rust-log" ,rust-log-0.4)
+ ("rust-signal-hook" ,rust-signal-hook-0.3)
+ ("rust-simple-logger" ,rust-simple-logger-1))
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'fix-paths
+ (lambda _
+ (substitute* "src/main.rs"
+ (("/usr/local") #$output))))
+ (add-after 'unpack 'remove-systemd-udev-rules
+ (lambda _
+ (substitute* "95-speakersafetyd.rules"
+ ((".*SYSTEMD_WANTS.*") ""))))
+ (add-after 'install 'install-data
+ (lambda _
+ (setenv "BINDIR" (string-append #$output "/bin"))
+ (setenv "UNITDIR" (string-append #$output "/lib/systemd/system"))
+ (setenv "UDEVDIR" (string-append #$output "/lib/udev/rules.d"))
+ (setenv "TMPFILESDIR" (string-append #$output "/usr/lib/tmpfiles.d"))
+ (setenv "SHAREDIR" (string-append #$output "/usr/share"))
+ (setenv "VARDIR" (string-append #$output "/var"))
+ (invoke "make" "install-data"))))))
+ (inputs (list alsa-lib))
+ (native-inputs (list pkg-config))
+ (home-page "https://github.com/AsahiLinux/speakersafetyd/")
+ (synopsis "Speaker protection daemon")
+ (description "Speakersafetyd is a userspace daemon written in Rust that
+implements an analogue of the Texas Instruments Smart Amp speaker protection
+model.")
+ (license license:expat)))
+
(define-public rust-special-0.8
(package
(name "rust-special")

base-commit: 54f82bcf22178d89140a131332a9e036ac386657
--
2.46.0
R
R
Roman Scherer wrote on 6 Nov 18:15 +0100
Re: [bug#74120] [PATCH] gnu: Add rust-speakersafetyd-1.
(name . Nicolas Graves)(address . ngraves@ngraves.fr)
86h68k8esn.fsf@burningswell.com
Nicolas Graves <ngraves@ngraves.fr> writes:

Hi Nicolas,

thanks for the review. I sent a v2 where I now use g-expressions and use
the install-data target from the Makefile to install files.

I tested this with this speakersafteyd service which I'm going to send
soon as well. I paste it here to maybe double check the paths I plan to
use in the service.

----------------------------------------------------------------------

(define-module (asahi guix services speakersafetyd)
#:use-module (asahi guix packages crates-io)
#:use-module (gnu services base)
#:use-module (gnu services shepherd)
#:use-module (gnu services)
#:use-module (guix gexp)
#:use-module (guix records)
#:export (speakersafetyd-service-type))

(define-record-type* <speakersafetyd-configuration>
speakersafetyd-configuration
make-speakersafetyd-configuration
speakersafetyd-configuration?
(config-path speakersafetyd-configuration-config-path
(default "/usr/share/speakersafetyd"))
(blackbox speakersafetyd-configuration-blackbox
(default "/var/lib/speakersafetyd/blackbox"))
(max-reduction speakersafetyd-configuration-max-reduction
(default 7))
(package speakersafetyd-configuration-package
(default rust-speakersafetyd-1)))

(define (speakersafetyd-shepherd-service config)
(let ((blackbox (speakersafetyd-configuration-blackbox config))
(config-path (speakersafetyd-configuration-config-path config))
(max-reduction (speakersafetyd-configuration-max-reduction config))
(package (speakersafetyd-configuration-package config)))
(list (shepherd-service
(documentation "Speaker saftey daemon")
(provision '(speakersafetyd))
(requirement '(udev))
(start #~(make-forkexec-constructor
(list #$(file-append package "/bin/speakersafetyd")
"--config-path" #$(file-append package config-path)
"--blackbox-path" #$blackbox
"--max-reduction" (number->string #$max-reduction))))
(stop #~(make-kill-destructor))))))

(define speakersafetyd-service-type
(service-type
(name 'speakersafetyd)
(description "Speaker saftey daemon")
(extensions
(list (service-extension
profile-service-type
(compose list speakersafetyd-configuration-package))
(service-extension
shepherd-root-service-type
speakersafetyd-shepherd-service)
(service-extension
udev-service-type
(compose list speakersafetyd-configuration-package))))
(default-value (speakersafetyd-configuration))))

----------------------------------------------------------------------

Could you have another look, please?

Thanks, Roman.

Toggle quote (6 lines)
> Hi Roman,
>
> Just so you know, you can probably use gexpressions for the phases, this
> would make it easier to read.
>
> Can you resend a revised patch? Thanks!
-----BEGIN PGP SIGNATURE-----

iQFLBAEBCAA1FiEE0iajOdjfRIFd3gygPdpSUn0qwZkFAmcrpBgXHHJvbWFuQGJ1
cm5pbmdzd2VsbC5jb20ACgkQPdpSUn0qwZmbOggArlDLyO6E5q7qJW5vkdDLK3GD
mpirrWzNcLYMM7aRoNSZ/1ci/siwoyQvIbY2slz2nUb8hIyg/nOOXYGpAMPV+K2d
+SCmqIaOo+vhMcQkdaJlZul+/WE/ly3SpdmXj2537ArpUmne10imS9Jw/5A9gXfX
W1EkgH3FdikNkOQml8f8SqxO0SAzV2Hcy2kqsbA1kb9S5Z5TI4xSZdNmOC5s+x8l
eU73albqeVh3iOE/JQyeae2TdsdOxFl1Uo0cuIua3BF3QF3C0epOp78U1CrXNAsz
NvQgN30+52CCVF+LmROh2onlLT5WdyvzPrxkxbPCetGnDZhDqgSfpBrq43SFAA==
=HG9O
-----END PGP SIGNATURE-----

?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 74120@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74120
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch