[PATCH 0/2] Add speakersafetyd system service.

  • Done
  • quality assurance status badge
Details
2 participants
  • Maxim Cournoyer
  • Roman Scherer
Owner
unassigned
Submitted by
Roman Scherer
Severity
normal

Debbugs page

Roman Scherer wrote 1 months ago
(address . guix-patches@gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)(address . efraim@flashner.co.il)
cover.1739540583.git.roman@burningswell.com
Hello Guix,

this patch series adds a system service for speakersafetyd [1], a userspace
daemon written in Rust that implements an analogue of the Texas Instruments
Smart Amp speaker protection model. It is developed and used by the Asahi
Linux project to protect the speakers on Apple Silicon devices.

The patch series contains 2 patches:

- The first one adjusts the SHAREDIR in the speakersafetyd package I submitted
earlier this year. The shared dir was wrong forcing users to specify it with
the --config-path option. Now just running speakersafetyd without any
options does the right thing, instead of complaining it could not find the
config.

- The second patch is the system service and its documentation.

Could you please review the patch series?

Thanks, Roman.


Roman Scherer (2):
gnu: speakersafetyd: Use correct shared directory.
services: Add speakersafetyd service.

doc/guix.texi | 41 +++++++++++++++++++++++++
gnu/packages/rust-apps.scm | 2 +-
gnu/services/sound.scm | 61 +++++++++++++++++++++++++++++++++++++-
3 files changed, 102 insertions(+), 2 deletions(-)


base-commit: 4b5f0408e66392ab745dc0f7830732217d88f17d
--
2.48.1
Roman Scherer wrote 1 months ago
[PATCH 1/2] gnu: speakersafetyd: Use correct shared directory.
(address . 76289@debbugs.gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)(address . efraim@flashner.co.il)
ec35bcc35165f10ca5eecda7a0920a46b3788173.1739540583.git.roman@burningswell.com
* gnu/packages/rust-apps.scm (speakersafetyd): Adjust shared directory.

Change-Id: If52576364f54394a2930d2d8750446acba389f6c
---
gnu/packages/rust-apps.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm
index f8da401bf7..90ec1ece2e 100644
--- a/gnu/packages/rust-apps.scm
+++ b/gnu/packages/rust-apps.scm
@@ -3203,7 +3203,7 @@ (define-public speakersafetyd
(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 "SHAREDIR" (string-append #$output "/share"))
(setenv "VARDIR" (string-append #$output "/var"))
(invoke "make" "install-data"))))))
(inputs (list alsa-lib))
--
2.48.1
Roman Scherer wrote 1 months ago
[PATCH 2/2] services: Add speakersafetyd service.
(address . 76289@debbugs.gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)(address . efraim@flashner.co.il)
6bdfd356508e8f643f2c63cb796548f36e0abb87.1739540583.git.roman@burningswell.com
* gnu/services/sound.scm (speakersafetyd-service-type) New variable.
* doc/guix.texi: Document the speakersafetyd service.

Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951
---
doc/guix.texi | 41 ++++++++++++++++++++++++++++
gnu/services/sound.scm | 61 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 101 insertions(+), 1 deletion(-)

Toggle diff (138 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index bd66adf326..3b82df5196 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -26575,6 +26575,47 @@ Sound Services
@end defvar
+@subsubheading Speaker Safety Daemon System Service
+
+@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety
+Daemon} is a userspace daemon that implements an analogue of the Texas
+Instruments Smart Amp speaker protection model. It can be used to
+protect the speakers on Apple Silicon devices.
+
+@defvar speakersafetyd-service-type
+This is the type for the @code{speakersafetyd} system service, whose
+value is a @command{speakersafetyd-configuration} record.
+
+@lisp
+(service speakersafetyd-service-type)
+@end lisp
+
+See below for details about @code{speakersafetyd-configuration}.
+@end defvar
+
+@deftp {Data Type} speakersafetyd-configuration
+Data type representing the configuration for @code{speakersafetyd-service}.
+
+@table @asis
+@item @code{blackbox-path} (default: @code{"/var/lib/speakersafetyd/blackbox"})
+The path to a directory to which "blackbox" files are written when the
+speakers are getting too hot. The blackbox files contain audio and
+debug information which the developers of @code{speakersafetyd} might
+ask for when reporting bugs.
+
+@item @code{config-path} (default: @code{(file-append speakersafetyd "/share/speakersafetyd")})
+Path to the base directory as a G-expression (@pxref{G-Expressions})
+that contains the configuration files of the speaker models.
+
+@item @code{max-reduction} (default: @code{7})
+Maximum gain reduction before panicing, useful for debugging.
+
+@item @code{package} (default: @var{speakersafetyd})
+The Speaker Safety Daemon package to use.
+
+@end table
+@end deftp
+
@node File Search Services
@subsection File Search Services
diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
index 8ca7acd737..fb8a8d3d17 100644
--- a/gnu/services/sound.scm
+++ b/gnu/services/sound.scm
@@ -35,6 +35,7 @@ (define-module (gnu services sound)
#:use-module (gnu packages audio)
#:use-module (gnu packages linux)
#:use-module (gnu packages pulseaudio)
+ #:use-module (gnu packages rust-apps)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:export (alsa-configuration
@@ -56,7 +57,15 @@ (define-module (gnu services sound)
ladspa-configuration
ladspa-configuration?
ladspa-configuration-plugins
- ladspa-service-type))
+ ladspa-service-type
+
+ speakersafetyd-configuration
+ speakersafetyd-configuration-blackbox-path
+ speakersafetyd-configuration-config-path
+ speakersafetyd-configuration-max-reduction
+ speakersafetyd-configuration-package
+ speakersafetyd-configuration?
+ speakersafetyd-service-type))
;;; Commentary:
;;;
@@ -263,4 +272,54 @@ (define ladspa-service-type
(default-value (ladspa-configuration))
(description "Configure LADSPA plugins.")))
+
+;;;
+;;; Speaker Safety Daemon
+;;;
+
+(define-record-type* <speakersafetyd-configuration>
+ speakersafetyd-configuration
+ make-speakersafetyd-configuration
+ speakersafetyd-configuration?
+ (blackbox-path speakersafetyd-configuration-blackbox-path
+ (default "/var/lib/speakersafetyd/blackbox"))
+ (config-path speakersafetyd-configuration-config-path
+ (default (file-append speakersafetyd "/share/speakersafetyd")))
+ (max-reduction speakersafetyd-configuration-max-reduction
+ (default 7))
+ (package speakersafetyd-configuration-package
+ (default speakersafetyd)))
+
+(define (speakersafetyd-shepherd-service config)
+ (let ((blackbox-path (speakersafetyd-configuration-blackbox-path config))
+ (config-path (speakersafetyd-configuration-config-path config))
+ (max-reduction (speakersafetyd-configuration-max-reduction config))
+ (package (speakersafetyd-configuration-package config)))
+ (shepherd-service
+ (documentation "Speaker saftey daemon")
+ (provision '(speakersafetyd))
+ (requirement '(udev))
+ (start #~(make-forkexec-constructor
+ (list #$(file-append package "/bin/speakersafetyd")
+ "--config-path" #$config-path
+ "--blackbox-path" #$blackbox-path
+ "--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
+ (compose list speakersafetyd-shepherd-service))
+ (service-extension
+ udev-service-type
+ (compose list speakersafetyd-configuration-package))))
+ (default-value (speakersafetyd-configuration))))
+
;;; sound.scm ends here
--
2.48.1
Maxim Cournoyer wrote 4 weeks ago
(name . Roman Scherer)(address . roman@burningswell.com)(name . Ludovic Cour tès)(address . ludo@gnu.org)(address . 76289@debbugs.gnu.org)(address . efraim@flashner.co.il)
87r0409fal.fsf@gmail.com
Hi Roman,

Roman Scherer <roman@burningswell.com> writes:

Toggle quote (3 lines)
> * gnu/services/sound.scm (speakersafetyd-service-type) New variable.
> * doc/guix.texi: Document the speakersafetyd service.

Interesting!

Toggle quote (103 lines)
> Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951
> ---
> doc/guix.texi | 41 ++++++++++++++++++++++++++++
> gnu/services/sound.scm | 61 +++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 101 insertions(+), 1 deletion(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index bd66adf326..3b82df5196 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -26575,6 +26575,47 @@ Sound Services
>
> @end defvar
>
> +@subsubheading Speaker Safety Daemon System Service
> +
> +@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety
> +Daemon} is a userspace daemon that implements an analogue of the Texas
> +Instruments Smart Amp speaker protection model. It can be used to
> +protect the speakers on Apple Silicon devices.
> +
> +@defvar speakersafetyd-service-type
> +This is the type for the @code{speakersafetyd} system service, whose
> +value is a @command{speakersafetyd-configuration} record.
> +
> +@lisp
> +(service speakersafetyd-service-type)
> +@end lisp
> +
> +See below for details about @code{speakersafetyd-configuration}.
> +@end defvar
> +
> +@deftp {Data Type} speakersafetyd-configuration
> +Data type representing the configuration for @code{speakersafetyd-service}.
> +
> +@table @asis
> +@item @code{blackbox-path} (default: @code{"/var/lib/speakersafetyd/blackbox"})
> +The path to a directory to which "blackbox" files are written when the
> +speakers are getting too hot. The blackbox files contain audio and
> +debug information which the developers of @code{speakersafetyd} might
> +ask for when reporting bugs.
> +
> +@item @code{config-path} (default: @code{(file-append speakersafetyd "/share/speakersafetyd")})
> +Path to the base directory as a G-expression (@pxref{G-Expressions})
> +that contains the configuration files of the speaker models.
> +
> +@item @code{max-reduction} (default: @code{7})
> +Maximum gain reduction before panicing, useful for debugging.
> +
> +@item @code{package} (default: @var{speakersafetyd})
> +The Speaker Safety Daemon package to use.
> +
> +@end table
> +@end deftp
> +
> @node File Search Services
> @subsection File Search Services
>
> diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
> index 8ca7acd737..fb8a8d3d17 100644
> --- a/gnu/services/sound.scm
> +++ b/gnu/services/sound.scm
> @@ -35,6 +35,7 @@ (define-module (gnu services sound)
> #:use-module (gnu packages audio)
> #:use-module (gnu packages linux)
> #:use-module (gnu packages pulseaudio)
> + #:use-module (gnu packages rust-apps)
> #:use-module (ice-9 match)
> #:use-module (srfi srfi-1)
> #:export (alsa-configuration
> @@ -56,7 +57,15 @@ (define-module (gnu services sound)
> ladspa-configuration
> ladspa-configuration?
> ladspa-configuration-plugins
> - ladspa-service-type))
> + ladspa-service-type
> +
> + speakersafetyd-configuration
> + speakersafetyd-configuration-blackbox-path
> + speakersafetyd-configuration-config-path
> + speakersafetyd-configuration-max-reduction
> + speakersafetyd-configuration-package
> + speakersafetyd-configuration?
> + speakersafetyd-service-type))
>
> ;;; Commentary:
> ;;;
> @@ -263,4 +272,54 @@ (define ladspa-service-type
> (default-value (ladspa-configuration))
> (description "Configure LADSPA plugins.")))
>
> +
> +;;;
> +;;; Speaker Safety Daemon
> +;;;
> +
> +(define-record-type* <speakersafetyd-configuration>
> + speakersafetyd-configuration
> + make-speakersafetyd-configuration
> + speakersafetyd-configuration?
> + (blackbox-path speakersafetyd-configuration-blackbox-path
> + (default "/var/lib/speakersafetyd/blackbox"))

Since these values are not serialized, we are free to name them the way
we like; so they should follow the GNU and Guix conventions, namely:

I'd use blackbox-directory.

Toggle quote (4 lines)
> + (config-path speakersafetyd-configuration-config-path
> + (default (file-append speakersafetyd
> "/share/speakersafetyd")))

I'd use configuration-directory.

Toggle quote (3 lines)
> + (max-reduction speakersafetyd-configuration-max-reduction
> + (default 7))

I'd use maximum-gain-reduction

Toggle quote (3 lines)
> + (package speakersafetyd-configuration-package
> + (default speakersafetyd)))

I'd use the more conventional
speakersafetyd-configuration-speakersafetyd (using the name of the
package as the field name).

Our related conventions here are roughly:

1. Prefer full name instead of abbreviation, especially in public APIs
2. Path always used to denote a multi-entries search path like 'PATH'
and friends. Use 'file name', 'file' or 'directory' instead.

It's also more conventional to use the package name for the package
object field, so here I'd use
'speakersafetyd-configuration-speakersafetyd'.

Could you please also use 'define-configuration/no-serialization' from
(gnu services configuration) ? It validates the type of each field and
produces useful user error messages in case these are incorrect.

Toggle quote (6 lines)
> +(define (speakersafetyd-shepherd-service config)
> + (let ((blackbox-path (speakersafetyd-configuration-blackbox-path config))
> + (config-path (speakersafetyd-configuration-config-path config))
> + (max-reduction (speakersafetyd-configuration-max-reduction config))
> + (package (speakersafetyd-configuration-package config)))

nitpick: I'd unbox each value using match-record; which will make things a bit
more concise.

Toggle quote (3 lines)
> + (shepherd-service
> + (documentation "Speaker saftey daemon")

s/saftey/safety/

Toggle quote (14 lines)
> + (provision '(speakersafetyd))
> + (requirement '(udev))
> + (start #~(make-forkexec-constructor
> + (list #$(file-append package "/bin/speakersafetyd")
> + "--config-path" #$config-path
> + "--blackbox-path" #$blackbox-path
> + "--max-reduction" (number->string #$max-reduction))))
> + (stop #~(make-kill-destructor)))))
> +
> +(define speakersafetyd-service-type
> + (service-type
> + (name 'speakersafetyd)
> + (description "Speaker Saftey Daemon")
>
s/Saftey/Safety/ The project has a better description, which can be
adapted to something like "@command{speakersafetyd} is a user space
daemon that implements an analogue of the Texas Instruments Smart Amp
speaker protection model."

Toggle quote (12 lines)
> + (extensions
> + (list (service-extension
> + profile-service-type
> + (compose list speakersafetyd-configuration-package))
> + (service-extension
> + shepherd-root-service-type
> + (compose list speakersafetyd-shepherd-service))
> + (service-extension
> + udev-service-type
> + (compose list speakersafetyd-configuration-package))))
> + (default-value (speakersafetyd-configuration))))

Nitpick, but I'd order these from most critical to less critical
ordering, such that te root service type is extended first, then the
udev-service-type, then the profile.

The rest LGTM. Could you please send a v2?

--
Thanks,
Maxim
Roman Scherer wrote 4 weeks ago
[PATCH v2 1/2] gnu: speakersafetyd: Use correct shared directory.
(address . 76289@debbugs.gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)
ec35bcc35165f10ca5eecda7a0920a46b3788173.1739609957.git.roman@burningswell.com
* gnu/packages/rust-apps.scm (speakersafetyd): Adjust shared directory.

Change-Id: If52576364f54394a2930d2d8750446acba389f6c
---
gnu/packages/rust-apps.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (17 lines)
diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm
index f8da401bf7..90ec1ece2e 100644
--- a/gnu/packages/rust-apps.scm
+++ b/gnu/packages/rust-apps.scm
@@ -3203,7 +3203,7 @@ (define-public speakersafetyd
(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 "SHAREDIR" (string-append #$output "/share"))
(setenv "VARDIR" (string-append #$output "/var"))
(invoke "make" "install-data"))))))
(inputs (list alsa-lib))

base-commit: 4b5f0408e66392ab745dc0f7830732217d88f17d
--
2.48.1
Roman Scherer wrote 4 weeks ago
[PATCH v2 2/2] services: Add speakersafetyd service.
(address . 76289@debbugs.gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)
5c054384d00cbfbe2181f266d0d2d38843a9a411.1739609957.git.roman@burningswell.com
* gnu/services/sound.scm (speakersafetyd-service-type) New variable.
* doc/guix.texi: Document the speakersafetyd service.

Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951
---
doc/guix.texi | 42 +++++++++++++++++++++++++++
gnu/services/sound.scm | 65 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 106 insertions(+), 1 deletion(-)

Toggle diff (143 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index bd66adf326..ec5c7ab5cf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -26575,6 +26575,48 @@ Sound Services
@end defvar
+@subsubheading Speaker Safety Daemon System Service
+
+@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety
+Daemon} is a user-space daemon that implements an analogue of the Texas
+Instruments Smart Amp speaker protection model. It can be used to
+protect the speakers on Apple Silicon devices.
+
+@defvar speakersafetyd-service-type
+This is the type for the @code{speakersafetyd} system service, whose
+value is a @command{speakersafetyd-configuration} record.
+
+@lisp
+(service speakersafetyd-service-type)
+@end lisp
+
+See below for details about @code{speakersafetyd-configuration}.
+@end defvar
+
+@deftp {Data Type} speakersafetyd-configuration
+Available @code{speakersafetyd-configuration} fields are:
+
+@table @asis
+@item @code{blackbox-directory} (default: @code{"/var/lib/speakersafetyd/blackbox"}) (type: string)
+The directory to which blackbox files are written when the speakers are
+getting too hot. The blackbox files contain audio and debug information
+which the developers of @code{speakersafetyd} might ask for when
+reporting bugs.
+
+@item @code{configuration-directory} (type: file-like)
+The base directory as a G-expression (@pxref{G-Expressions}) that
+contains the configuration files of the speaker models.
+
+@item @code{maximum-gain-reduction} (default: @code{7}) (type: integer)
+Maximum gain reduction before panicing, useful for debugging.
+
+@item @code{speakersafetyd} (default: @code{speakersafetyd}) (type: file-like)
+The Speaker Safety Daemon package to use.
+
+@end table
+
+@end deftp
+
@node File Search Services
@subsection File Search Services
diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
index 8ca7acd737..9418969e9e 100644
--- a/gnu/services/sound.scm
+++ b/gnu/services/sound.scm
@@ -35,6 +35,7 @@ (define-module (gnu services sound)
#:use-module (gnu packages audio)
#:use-module (gnu packages linux)
#:use-module (gnu packages pulseaudio)
+ #:use-module (gnu packages rust-apps)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:export (alsa-configuration
@@ -56,7 +57,15 @@ (define-module (gnu services sound)
ladspa-configuration
ladspa-configuration?
ladspa-configuration-plugins
- ladspa-service-type))
+ ladspa-service-type
+
+ speakersafetyd-configuration
+ speakersafetyd-configuration-blackbox-directory
+ speakersafetyd-configuration-directory
+ speakersafetyd-configuration-maximum-gain-reduction
+ speakersafetyd-configuration-speakersafetyd
+ speakersafetyd-configuration?
+ speakersafetyd-service-type))
;;; Commentary:
;;;
@@ -263,4 +272,58 @@ (define ladspa-service-type
(default-value (ladspa-configuration))
(description "Configure LADSPA plugins.")))
+
+;;;
+;;; Speaker Safety Daemon
+;;;
+
+(define-configuration/no-serialization speakersafetyd-configuration
+ (blackbox-directory
+ (string "/var/lib/speakersafetyd/blackbox")
+ "The directory to which blackbox files are written when the speakers are
+getting too hot. The blackbox files contain audio and debug information which
+the developers of @code{speakersafetyd} might ask for when reporting bugs.")
+ (configuration-directory
+ (file-like (file-append speakersafetyd "/share/speakersafetyd"))
+ "The base directory as a G-expression (@pxref{G-Expressions}) that contains
+the configuration files of the speaker models.")
+ (maximum-gain-reduction
+ (integer 7)
+ "Maximum gain reduction before panicing, useful for debugging.")
+ (speakersafetyd
+ (file-like speakersafetyd)
+ "The Speaker Safety Daemon package to use."))
+
+(define speakersafetyd-shepherd-service
+ (match-record-lambda <speakersafetyd-configuration>
+ (blackbox-directory configuration-directory maximum-gain-reduction speakersafetyd)
+ (shepherd-service
+ (documentation "Run the speaker safety daemon")
+ (provision '(speakersafetyd))
+ (requirement '(udev))
+ (start #~(make-forkexec-constructor
+ (list #$(file-append speakersafetyd "/bin/speakersafetyd")
+ "--config-path" #$configuration-directory
+ "--blackbox-path" #$blackbox-directory
+ "--max-reduction" (number->string #$maximum-gain-reduction))))
+ (stop #~(make-kill-destructor)))))
+
+(define speakersafetyd-service-type
+ (service-type
+ (name 'speakersafetyd)
+ (description "Run @command{speakersafetyd}, a user space daemon that
+implements an analogue of the Texas Instruments Smart Amp speaker protection
+model. It can be used to protect the speakers on Apple Silicon devices.")
+ (extensions
+ (list (service-extension
+ shepherd-root-service-type
+ (compose list speakersafetyd-shepherd-service))
+ (service-extension
+ udev-service-type
+ (compose list speakersafetyd-configuration-speakersafetyd))
+ (service-extension
+ profile-service-type
+ (compose list speakersafetyd-configuration-speakersafetyd))))
+ (default-value (speakersafetyd-configuration))))
+
;;; sound.scm ends here
--
2.48.1
Roman Scherer wrote 4 weeks ago
Re: [bug#76289] [PATCH 2/2] services: Add speakersafetyd service.
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(name . Roman Scherer)(address . roman@burningswell.com)(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 76289@debbugs.gnu.org)(address . efraim@flashner.co.il)
877c5rtvpy.fsf@burningswell.com
Hi Maxim,

thanks for your review. I hope I addressed your comments. Additionally:

- I used the configuration->documentation command to generate
documentation from the configuration record

- I discovered match-record-lambda and use this instead of match-record

Could you have another look please?

Thank you, Roman.

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (199 lines)
> Hi Roman,
>
> Roman Scherer <roman@burningswell.com> writes:
>
>> * gnu/services/sound.scm (speakersafetyd-service-type) New variable.
>> * doc/guix.texi: Document the speakersafetyd service.
>
> Interesting!
>
>> Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951
>> ---
>> doc/guix.texi | 41 ++++++++++++++++++++++++++++
>> gnu/services/sound.scm | 61 +++++++++++++++++++++++++++++++++++++++++-
>> 2 files changed, 101 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index bd66adf326..3b82df5196 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -26575,6 +26575,47 @@ Sound Services
>>
>> @end defvar
>>
>> +@subsubheading Speaker Safety Daemon System Service
>> +
>> +@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety
>> +Daemon} is a userspace daemon that implements an analogue of the Texas
>> +Instruments Smart Amp speaker protection model. It can be used to
>> +protect the speakers on Apple Silicon devices.
>> +
>> +@defvar speakersafetyd-service-type
>> +This is the type for the @code{speakersafetyd} system service, whose
>> +value is a @command{speakersafetyd-configuration} record.
>> +
>> +@lisp
>> +(service speakersafetyd-service-type)
>> +@end lisp
>> +
>> +See below for details about @code{speakersafetyd-configuration}.
>> +@end defvar
>> +
>> +@deftp {Data Type} speakersafetyd-configuration
>> +Data type representing the configuration for @code{speakersafetyd-service}.
>> +
>> +@table @asis
>> +@item @code{blackbox-path} (default: @code{"/var/lib/speakersafetyd/blackbox"})
>> +The path to a directory to which "blackbox" files are written when the
>> +speakers are getting too hot. The blackbox files contain audio and
>> +debug information which the developers of @code{speakersafetyd} might
>> +ask for when reporting bugs.
>> +
>> +@item @code{config-path} (default: @code{(file-append speakersafetyd "/share/speakersafetyd")})
>> +Path to the base directory as a G-expression (@pxref{G-Expressions})
>> +that contains the configuration files of the speaker models.
>> +
>> +@item @code{max-reduction} (default: @code{7})
>> +Maximum gain reduction before panicing, useful for debugging.
>> +
>> +@item @code{package} (default: @var{speakersafetyd})
>> +The Speaker Safety Daemon package to use.
>> +
>> +@end table
>> +@end deftp
>> +
>> @node File Search Services
>> @subsection File Search Services
>>
>> diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
>> index 8ca7acd737..fb8a8d3d17 100644
>> --- a/gnu/services/sound.scm
>> +++ b/gnu/services/sound.scm
>> @@ -35,6 +35,7 @@ (define-module (gnu services sound)
>> #:use-module (gnu packages audio)
>> #:use-module (gnu packages linux)
>> #:use-module (gnu packages pulseaudio)
>> + #:use-module (gnu packages rust-apps)
>> #:use-module (ice-9 match)
>> #:use-module (srfi srfi-1)
>> #:export (alsa-configuration
>> @@ -56,7 +57,15 @@ (define-module (gnu services sound)
>> ladspa-configuration
>> ladspa-configuration?
>> ladspa-configuration-plugins
>> - ladspa-service-type))
>> + ladspa-service-type
>> +
>> + speakersafetyd-configuration
>> + speakersafetyd-configuration-blackbox-path
>> + speakersafetyd-configuration-config-path
>> + speakersafetyd-configuration-max-reduction
>> + speakersafetyd-configuration-package
>> + speakersafetyd-configuration?
>> + speakersafetyd-service-type))
>>
>> ;;; Commentary:
>> ;;;
>> @@ -263,4 +272,54 @@ (define ladspa-service-type
>> (default-value (ladspa-configuration))
>> (description "Configure LADSPA plugins.")))
>>
>> +
>> +;;;
>> +;;; Speaker Safety Daemon
>> +;;;
>> +
>> +(define-record-type* <speakersafetyd-configuration>
>> + speakersafetyd-configuration
>> + make-speakersafetyd-configuration
>> + speakersafetyd-configuration?
>> + (blackbox-path speakersafetyd-configuration-blackbox-path
>> + (default "/var/lib/speakersafetyd/blackbox"))
>
> Since these values are not serialized, we are free to name them the way
> we like; so they should follow the GNU and Guix conventions, namely:
>
> I'd use blackbox-directory.
>
>> + (config-path speakersafetyd-configuration-config-path
>> + (default (file-append speakersafetyd
>> "/share/speakersafetyd")))
>
> I'd use configuration-directory.
>
>> + (max-reduction speakersafetyd-configuration-max-reduction
>> + (default 7))
>
> I'd use maximum-gain-reduction
>
>> + (package speakersafetyd-configuration-package
>> + (default speakersafetyd)))
>
> I'd use the more conventional
> speakersafetyd-configuration-speakersafetyd (using the name of the
> package as the field name).
>
> Our related conventions here are roughly:
>
> 1. Prefer full name instead of abbreviation, especially in public APIs
> 2. Path always used to denote a multi-entries search path like 'PATH'
> and friends. Use 'file name', 'file' or 'directory' instead.
>
> It's also more conventional to use the package name for the package
> object field, so here I'd use
> 'speakersafetyd-configuration-speakersafetyd'.
>
> Could you please also use 'define-configuration/no-serialization' from
> (gnu services configuration) ? It validates the type of each field and
> produces useful user error messages in case these are incorrect.
>
>> +(define (speakersafetyd-shepherd-service config)
>> + (let ((blackbox-path (speakersafetyd-configuration-blackbox-path config))
>> + (config-path (speakersafetyd-configuration-config-path config))
>> + (max-reduction (speakersafetyd-configuration-max-reduction config))
>> + (package (speakersafetyd-configuration-package config)))
>
> nitpick: I'd unbox each value using match-record; which will make things a bit
> more concise.
>
>> + (shepherd-service
>> + (documentation "Speaker saftey daemon")
>
> s/saftey/safety/
>
>> + (provision '(speakersafetyd))
>> + (requirement '(udev))
>> + (start #~(make-forkexec-constructor
>> + (list #$(file-append package "/bin/speakersafetyd")
>> + "--config-path" #$config-path
>> + "--blackbox-path" #$blackbox-path
>> + "--max-reduction" (number->string #$max-reduction))))
>> + (stop #~(make-kill-destructor)))))
>> +
>> +(define speakersafetyd-service-type
>> + (service-type
>> + (name 'speakersafetyd)
>> + (description "Speaker Saftey Daemon")
>>
> s/Saftey/Safety/ The project has a better description, which can be
> adapted to something like "@command{speakersafetyd} is a user space
> daemon that implements an analogue of the Texas Instruments Smart Amp
> speaker protection model."
>
>> + (extensions
>> + (list (service-extension
>> + profile-service-type
>> + (compose list speakersafetyd-configuration-package))
>> + (service-extension
>> + shepherd-root-service-type
>> + (compose list speakersafetyd-shepherd-service))
>> + (service-extension
>> + udev-service-type
>> + (compose list speakersafetyd-configuration-package))))
>> + (default-value (speakersafetyd-configuration))))
>
> Nitpick, but I'd order these from most critical to less critical
> ordering, such that te root service type is extended first, then the
> udev-service-type, then the profile.
>
> The rest LGTM. Could you please send a v2?
-----BEGIN PGP SIGNATURE-----

iQFLBAEBCAA1FiEE0iajOdjfRIFd3gygPdpSUn0qwZkFAmewWykXHHJvbWFuQGJ1
cm5pbmdzd2VsbC5jb20ACgkQPdpSUn0qwZnvhgf/SsJC8ImQDyCwx0odfvvazZZY
yz/TpPIk/NGO5QQMPwkQfadfnrcanJ/zqjuG++mT1x7h0HBEEDUaDq7CgrzOF6MQ
px5vwKD5toEFSUY22YVFnWXZvU3/UTmY3x/fK6k0tIXjkeBAXzEX8dyH+qnAYHUJ
YA9OVJI4LJhfovlO36Zm/0iiLQ6cPMotEzMS3TYAmtFdWVoFtdIwRCROhzyCEJFw
SA0H3K+sDKQdl31b/2JCxaPd2lDwQtSWIMm+fAdG7zYZ/glXJdgmhnzfBjg/LCmx
eIXrA75dWXPAjALB3XogHswFHcdZoSPESIl9x6TV974w0YO070q7VAIQaNgVbg==
=6HQR
-----END PGP SIGNATURE-----

Roman Scherer wrote 4 weeks ago
[PATCH v3 1/2] gnu: speakersafetyd: Use correct shared directory.
(address . 76289@debbugs.gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)
ec35bcc35165f10ca5eecda7a0920a46b3788173.1739611331.git.roman@burningswell.com
* gnu/packages/rust-apps.scm (speakersafetyd): Adjust shared directory.

Change-Id: If52576364f54394a2930d2d8750446acba389f6c
---
gnu/packages/rust-apps.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (17 lines)
diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm
index f8da401bf7..90ec1ece2e 100644
--- a/gnu/packages/rust-apps.scm
+++ b/gnu/packages/rust-apps.scm
@@ -3203,7 +3203,7 @@ (define-public speakersafetyd
(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 "SHAREDIR" (string-append #$output "/share"))
(setenv "VARDIR" (string-append #$output "/var"))
(invoke "make" "install-data"))))))
(inputs (list alsa-lib))

base-commit: 4b5f0408e66392ab745dc0f7830732217d88f17d
--
2.48.1
Roman Scherer wrote 4 weeks ago
[PATCH v3 2/2] services: Add speakersafetyd service.
(address . 76289@debbugs.gnu.org)(name . Roman Scherer)(address . roman@burningswell.com)
b8d40b58bf72848f6efca1dd3a5b464452fc9b99.1739611331.git.roman@burningswell.com
* gnu/services/sound.scm (speakersafetyd-service-type) New variable.
* doc/guix.texi: Document the speakersafetyd service.

Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951
---
doc/guix.texi | 42 +++++++++++++++++++++++++++
gnu/services/sound.scm | 65 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 106 insertions(+), 1 deletion(-)

Toggle diff (143 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index bd66adf326..ec5c7ab5cf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -26575,6 +26575,48 @@ Sound Services
@end defvar
+@subsubheading Speaker Safety Daemon System Service
+
+@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety
+Daemon} is a user-space daemon that implements an analogue of the Texas
+Instruments Smart Amp speaker protection model. It can be used to
+protect the speakers on Apple Silicon devices.
+
+@defvar speakersafetyd-service-type
+This is the type for the @code{speakersafetyd} system service, whose
+value is a @command{speakersafetyd-configuration} record.
+
+@lisp
+(service speakersafetyd-service-type)
+@end lisp
+
+See below for details about @code{speakersafetyd-configuration}.
+@end defvar
+
+@deftp {Data Type} speakersafetyd-configuration
+Available @code{speakersafetyd-configuration} fields are:
+
+@table @asis
+@item @code{blackbox-directory} (default: @code{"/var/lib/speakersafetyd/blackbox"}) (type: string)
+The directory to which blackbox files are written when the speakers are
+getting too hot. The blackbox files contain audio and debug information
+which the developers of @code{speakersafetyd} might ask for when
+reporting bugs.
+
+@item @code{configuration-directory} (type: file-like)
+The base directory as a G-expression (@pxref{G-Expressions}) that
+contains the configuration files of the speaker models.
+
+@item @code{maximum-gain-reduction} (default: @code{7}) (type: integer)
+Maximum gain reduction before panicing, useful for debugging.
+
+@item @code{speakersafetyd} (default: @code{speakersafetyd}) (type: file-like)
+The Speaker Safety Daemon package to use.
+
+@end table
+
+@end deftp
+
@node File Search Services
@subsection File Search Services
diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
index 8ca7acd737..bf7d3cc6b0 100644
--- a/gnu/services/sound.scm
+++ b/gnu/services/sound.scm
@@ -35,6 +35,7 @@ (define-module (gnu services sound)
#:use-module (gnu packages audio)
#:use-module (gnu packages linux)
#:use-module (gnu packages pulseaudio)
+ #:use-module (gnu packages rust-apps)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:export (alsa-configuration
@@ -56,7 +57,15 @@ (define-module (gnu services sound)
ladspa-configuration
ladspa-configuration?
ladspa-configuration-plugins
- ladspa-service-type))
+ ladspa-service-type
+
+ speakersafetyd-configuration
+ speakersafetyd-configuration-blackbox-directory
+ speakersafetyd-configuration-configuration-directory
+ speakersafetyd-configuration-maximum-gain-reduction
+ speakersafetyd-configuration-speakersafetyd
+ speakersafetyd-configuration?
+ speakersafetyd-service-type))
;;; Commentary:
;;;
@@ -263,4 +272,58 @@ (define ladspa-service-type
(default-value (ladspa-configuration))
(description "Configure LADSPA plugins.")))
+
+;;;
+;;; Speaker Safety Daemon
+;;;
+
+(define-configuration/no-serialization speakersafetyd-configuration
+ (blackbox-directory
+ (string "/var/lib/speakersafetyd/blackbox")
+ "The directory to which blackbox files are written when the speakers are
+getting too hot. The blackbox files contain audio and debug information which
+the developers of @code{speakersafetyd} might ask for when reporting bugs.")
+ (configuration-directory
+ (file-like (file-append speakersafetyd "/share/speakersafetyd"))
+ "The base directory as a G-expression (@pxref{G-Expressions}) that contains
+the configuration files of the speaker models.")
+ (maximum-gain-reduction
+ (integer 7)
+ "Maximum gain reduction before panicing, useful for debugging.")
+ (speakersafetyd
+ (file-like speakersafetyd)
+ "The Speaker Safety Daemon package to use."))
+
+(define speakersafetyd-shepherd-service
+ (match-record-lambda <speakersafetyd-configuration>
+ (blackbox-directory configuration-directory maximum-gain-reduction speakersafetyd)
+ (shepherd-service
+ (documentation "Run the speaker safety daemon")
+ (provision '(speakersafetyd))
+ (requirement '(udev))
+ (start #~(make-forkexec-constructor
+ (list #$(file-append speakersafetyd "/bin/speakersafetyd")
+ "--config-path" #$configuration-directory
+ "--blackbox-path" #$blackbox-directory
+ "--max-reduction" (number->string #$maximum-gain-reduction))))
+ (stop #~(make-kill-destructor)))))
+
+(define speakersafetyd-service-type
+ (service-type
+ (name 'speakersafetyd)
+ (description "Run @command{speakersafetyd}, a user space daemon that
+implements an analogue of the Texas Instruments Smart Amp speaker protection
+model. It can be used to protect the speakers on Apple Silicon devices.")
+ (extensions
+ (list (service-extension
+ shepherd-root-service-type
+ (compose list speakersafetyd-shepherd-service))
+ (service-extension
+ udev-service-type
+ (compose list speakersafetyd-configuration-speakersafetyd))
+ (service-extension
+ profile-service-type
+ (compose list speakersafetyd-configuration-speakersafetyd))))
+ (default-value (speakersafetyd-configuration))))
+
;;; sound.scm ends here
--
2.48.1
Roman Scherer wrote 4 weeks ago
Re: [bug#76289] [PATCH 2/2] services: Add speakersafetyd service.
(name . Roman Scherer)(address . roman@burningswell.com)(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 76289@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . efraim@flashner.co.il)
86a5an5zks.fsf@burningswell.com
And I just send a v3, because I exported the wrong symbol.

Roman Scherer <roman@burningswell.com> writes:

Toggle quote (214 lines)
> Hi Maxim,
>
> thanks for your review. I hope I addressed your comments. Additionally:
>
> - I used the configuration->documentation command to generate
> documentation from the configuration record
>
> - I discovered match-record-lambda and use this instead of match-record
>
> Could you have another look please?
>
> Thank you, Roman.
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
>
>> Hi Roman,
>>
>> Roman Scherer <roman@burningswell.com> writes:
>>
>>> * gnu/services/sound.scm (speakersafetyd-service-type) New variable.
>>> * doc/guix.texi: Document the speakersafetyd service.
>>
>> Interesting!
>>
>>> Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951
>>> ---
>>> doc/guix.texi | 41 ++++++++++++++++++++++++++++
>>> gnu/services/sound.scm | 61 +++++++++++++++++++++++++++++++++++++++++-
>>> 2 files changed, 101 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/doc/guix.texi b/doc/guix.texi
>>> index bd66adf326..3b82df5196 100644
>>> --- a/doc/guix.texi
>>> +++ b/doc/guix.texi
>>> @@ -26575,6 +26575,47 @@ Sound Services
>>>
>>> @end defvar
>>>
>>> +@subsubheading Speaker Safety Daemon System Service
>>> +
>>> +@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety
>>> +Daemon} is a userspace daemon that implements an analogue of the Texas
>>> +Instruments Smart Amp speaker protection model. It can be used to
>>> +protect the speakers on Apple Silicon devices.
>>> +
>>> +@defvar speakersafetyd-service-type
>>> +This is the type for the @code{speakersafetyd} system service, whose
>>> +value is a @command{speakersafetyd-configuration} record.
>>> +
>>> +@lisp
>>> +(service speakersafetyd-service-type)
>>> +@end lisp
>>> +
>>> +See below for details about @code{speakersafetyd-configuration}.
>>> +@end defvar
>>> +
>>> +@deftp {Data Type} speakersafetyd-configuration
>>> +Data type representing the configuration for @code{speakersafetyd-service}.
>>> +
>>> +@table @asis
>>> +@item @code{blackbox-path} (default: @code{"/var/lib/speakersafetyd/blackbox"})
>>> +The path to a directory to which "blackbox" files are written when the
>>> +speakers are getting too hot. The blackbox files contain audio and
>>> +debug information which the developers of @code{speakersafetyd} might
>>> +ask for when reporting bugs.
>>> +
>>> +@item @code{config-path} (default: @code{(file-append speakersafetyd "/share/speakersafetyd")})
>>> +Path to the base directory as a G-expression (@pxref{G-Expressions})
>>> +that contains the configuration files of the speaker models.
>>> +
>>> +@item @code{max-reduction} (default: @code{7})
>>> +Maximum gain reduction before panicing, useful for debugging.
>>> +
>>> +@item @code{package} (default: @var{speakersafetyd})
>>> +The Speaker Safety Daemon package to use.
>>> +
>>> +@end table
>>> +@end deftp
>>> +
>>> @node File Search Services
>>> @subsection File Search Services
>>>
>>> diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
>>> index 8ca7acd737..fb8a8d3d17 100644
>>> --- a/gnu/services/sound.scm
>>> +++ b/gnu/services/sound.scm
>>> @@ -35,6 +35,7 @@ (define-module (gnu services sound)
>>> #:use-module (gnu packages audio)
>>> #:use-module (gnu packages linux)
>>> #:use-module (gnu packages pulseaudio)
>>> + #:use-module (gnu packages rust-apps)
>>> #:use-module (ice-9 match)
>>> #:use-module (srfi srfi-1)
>>> #:export (alsa-configuration
>>> @@ -56,7 +57,15 @@ (define-module (gnu services sound)
>>> ladspa-configuration
>>> ladspa-configuration?
>>> ladspa-configuration-plugins
>>> - ladspa-service-type))
>>> + ladspa-service-type
>>> +
>>> + speakersafetyd-configuration
>>> + speakersafetyd-configuration-blackbox-path
>>> + speakersafetyd-configuration-config-path
>>> + speakersafetyd-configuration-max-reduction
>>> + speakersafetyd-configuration-package
>>> + speakersafetyd-configuration?
>>> + speakersafetyd-service-type))
>>>
>>> ;;; Commentary:
>>> ;;;
>>> @@ -263,4 +272,54 @@ (define ladspa-service-type
>>> (default-value (ladspa-configuration))
>>> (description "Configure LADSPA plugins.")))
>>>
>>> +
>>> +;;;
>>> +;;; Speaker Safety Daemon
>>> +;;;
>>> +
>>> +(define-record-type* <speakersafetyd-configuration>
>>> + speakersafetyd-configuration
>>> + make-speakersafetyd-configuration
>>> + speakersafetyd-configuration?
>>> + (blackbox-path speakersafetyd-configuration-blackbox-path
>>> + (default "/var/lib/speakersafetyd/blackbox"))
>>
>> Since these values are not serialized, we are free to name them the way
>> we like; so they should follow the GNU and Guix conventions, namely:
>>
>> I'd use blackbox-directory.
>>
>>> + (config-path speakersafetyd-configuration-config-path
>>> + (default (file-append speakersafetyd
>>> "/share/speakersafetyd")))
>>
>> I'd use configuration-directory.
>>
>>> + (max-reduction speakersafetyd-configuration-max-reduction
>>> + (default 7))
>>
>> I'd use maximum-gain-reduction
>>
>>> + (package speakersafetyd-configuration-package
>>> + (default speakersafetyd)))
>>
>> I'd use the more conventional
>> speakersafetyd-configuration-speakersafetyd (using the name of the
>> package as the field name).
>>
>> Our related conventions here are roughly:
>>
>> 1. Prefer full name instead of abbreviation, especially in public APIs
>> 2. Path always used to denote a multi-entries search path like 'PATH'
>> and friends. Use 'file name', 'file' or 'directory' instead.
>>
>> It's also more conventional to use the package name for the package
>> object field, so here I'd use
>> 'speakersafetyd-configuration-speakersafetyd'.
>>
>> Could you please also use 'define-configuration/no-serialization' from
>> (gnu services configuration) ? It validates the type of each field and
>> produces useful user error messages in case these are incorrect.
>>
>>> +(define (speakersafetyd-shepherd-service config)
>>> + (let ((blackbox-path (speakersafetyd-configuration-blackbox-path config))
>>> + (config-path (speakersafetyd-configuration-config-path config))
>>> + (max-reduction (speakersafetyd-configuration-max-reduction config))
>>> + (package (speakersafetyd-configuration-package config)))
>>
>> nitpick: I'd unbox each value using match-record; which will make things a bit
>> more concise.
>>
>>> + (shepherd-service
>>> + (documentation "Speaker saftey daemon")
>>
>> s/saftey/safety/
>>
>>> + (provision '(speakersafetyd))
>>> + (requirement '(udev))
>>> + (start #~(make-forkexec-constructor
>>> + (list #$(file-append package "/bin/speakersafetyd")
>>> + "--config-path" #$config-path
>>> + "--blackbox-path" #$blackbox-path
>>> + "--max-reduction" (number->string #$max-reduction))))
>>> + (stop #~(make-kill-destructor)))))
>>> +
>>> +(define speakersafetyd-service-type
>>> + (service-type
>>> + (name 'speakersafetyd)
>>> + (description "Speaker Saftey Daemon")
>>>
>> s/Saftey/Safety/ The project has a better description, which can be
>> adapted to something like "@command{speakersafetyd} is a user space
>> daemon that implements an analogue of the Texas Instruments Smart Amp
>> speaker protection model."
>>
>>> + (extensions
>>> + (list (service-extension
>>> + profile-service-type
>>> + (compose list speakersafetyd-configuration-package))
>>> + (service-extension
>>> + shepherd-root-service-type
>>> + (compose list speakersafetyd-shepherd-service))
>>> + (service-extension
>>> + udev-service-type
>>> + (compose list speakersafetyd-configuration-package))))
>>> + (default-value (speakersafetyd-configuration))))
>>
>> Nitpick, but I'd order these from most critical to less critical
>> ordering, such that te root service type is extended first, then the
>> udev-service-type, then the profile.
>>
>> The rest LGTM. Could you please send a v2?
-----BEGIN PGP SIGNATURE-----

iQFLBAEBCAA1FiEE0iajOdjfRIFd3gygPdpSUn0qwZkFAmewXaMXHHJvbWFuQGJ1
cm5pbmdzd2VsbC5jb20ACgkQPdpSUn0qwZnYXQgApaUmikCkRVWr8svzWbtlUvhK
1rox5wKYSIHvuZjCQ5tUg64gq2n+lHrenkjm2Cro3U587HYbnSymUxr5bjMXTUqB
Rbbf0xXHjsJ8wmxKUDIYrmxWVJWj0CdCHojo5dCF9smynI8SaWfPYo1Gcl+wSDQn
q6uHL9S8c9WPjnUb7jyyfasGuuoqdMaVuuFoCPo6IzrB8OP5cxUB+iiBOECV/Pm7
koEQ1TUoGyHfMb6HcP3n19qhwiRTtcN0gQChKUP1RxponN54e7nyDsznG53GpXZD
eumiN65JW6Q8jC1XPtormq6Su/WsJYtYTxXEOX7h0oVYC/qCUl7Z8yWoTEwyug==
=PM5K
-----END PGP SIGNATURE-----

Maxim Cournoyer wrote 4 weeks ago
Re: [bug#76289] [PATCH v3 2/2] services: Add speakersafetyd service.
(name . Roman Scherer)(address . roman@burningswell.com)(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 76289-done@debbugs.gnu.org)
877c5r8edv.fsf@gmail.com
Hi,

Roman Scherer <roman@burningswell.com> writes:

Toggle quote (5 lines)
> * gnu/services/sound.scm (speakersafetyd-service-type) New variable.
> * doc/guix.texi: Document the speakersafetyd service.
>
> Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951

I've made the following small adjustments:

Toggle snippet (56 lines)
modified doc/guix.texi
@@ -26593,6 +26593,7 @@ Sound Services
See below for details about @code{speakersafetyd-configuration}.
@end defvar
+@c %start of fragment
@deftp {Data Type} speakersafetyd-configuration
Available @code{speakersafetyd-configuration} fields are:
@@ -26608,14 +26609,14 @@ Sound Services
contains the configuration files of the speaker models.
@item @code{maximum-gain-reduction} (default: @code{7}) (type: integer)
-Maximum gain reduction before panicing, useful for debugging.
+Maximum gain reduction before panicking, useful for debugging.
@item @code{speakersafetyd} (default: @code{speakersafetyd}) (type: file-like)
The Speaker Safety Daemon package to use.
@end table
-
@end deftp
+@c %end of fragment
@node File Search Services
@subsection File Search Services
modified gnu/services/sound.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2020 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2025 Roman Scherer <roman@burningswell.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -274,7 +275,7 @@ (define ladspa-service-type
;;;
-;;; Speaker Safety Daemon
+;;; Speaker Safety Daemon.
;;;
(define-configuration/no-serialization speakersafetyd-configuration
@@ -289,7 +290,7 @@ (define-configuration/no-serialization speakersafetyd-configuration
the configuration files of the speaker models.")
(maximum-gain-reduction
(integer 7)
- "Maximum gain reduction before panicing, useful for debugging.")
+ "Maximum gain reduction before panicking, useful for debugging.")
(speakersafetyd
(file-like speakersafetyd)
"The Speaker Safety Daemon package to use."))


And expound the changelog a bit to:

Toggle snippet (8 lines)
services: Add speakersafetyd service.

* gnu/services/sound.scm (speakersafetyd-shepherd-service)
(speakersafetyd-configuration)
(speakersafetyd-service-type): New variables.
* doc/guix.texi (Sound Services): Document it.

And pushed as commit af643735a5.

Thank you for your contribution! Closing by replying to
76289-done@debbugs.gnu.org in CC.

--
Thanks,
Maxim
Closed
Maxim Cournoyer wrote 4 weeks ago
Re: [bug#76289] [PATCH 2/2] services: Add speakersafetyd service.
(name . Roman Scherer)(address . roman@burningswell.com)(name . Ludovic Courtès)(address . ludo@gnu.org)(address . efraim@flashner.co.il)(address . 76289-done@debbugs.gnu.org)
8734gf8eay.fsf@gmail.com
Hi Roman,

Roman Scherer <roman@burningswell.com> writes:

[...]

Toggle quote (5 lines)
>> thanks for your review. I hope I addressed your comments. Additionally:
>>
>> - I used the configuration->documentation command to generate
>> documentation from the configuration record

That's how it's currently intended to be used (more automation would be
welcome :-))

Toggle quote (2 lines)
>> - I discovered match-record-lambda and use this instead of match-record

Neat, I ddn't know about it.

Toggle quote (2 lines)
>> Could you have another look please?

It's now merged.

--
Thanks,
Maxim
Closed
Roman Scherer wrote 4 weeks ago
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(name . Roman Scherer)(address . roman@burningswell.com)(name . Ludovic Courtès)(address . ludo@gnu.org)(address . efraim@flashner.co.il)(address . 76289-done@debbugs.gnu.org)
86wmdrb6zk.fsf@burningswell.com
Hi Maxim,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (14 lines)
> Hi Roman,
>
> Roman Scherer <roman@burningswell.com> writes:
>
> [...]
>
>>> thanks for your review. I hope I addressed your comments. Additionally:
>>>
>>> - I used the configuration->documentation command to generate
>>> documentation from the configuration record
>
> That's how it's currently intended to be used (more automation would be
> welcome :-))

+1

Toggle quote (8 lines)
>>> - I discovered match-record-lambda and use this instead of match-record
>
> Neat, I ddn't know about it.
>
>>> Could you have another look please?
>
> It's now merged.

Nice, thank you!
-----BEGIN PGP SIGNATURE-----

iQFLBAEBCAA1FiEE0iajOdjfRIFd3gygPdpSUn0qwZkFAmewqN8XHHJvbWFuQGJ1
cm5pbmdzd2VsbC5jb20ACgkQPdpSUn0qwZkkPQf9EyhXNpcT8Ht5P1ivR1S5BS7o
Its9Rx/qLh32uPsiayFHz4YLpKH5j+ahfsYWnXExm6GdDEPHoD/DkOxVexncCOzp
4cl/CjWkos45FoQaLM2uJKntdKOwFfVcSwXvMccDAUSTHksYQrJ2YSL2fzQf3hrB
B/jEhiDn+eoARKJs5d4wPK74MNfhVfCL4wkkyeYMOuS9ehhhzhdElb65fdjBhEC0
XdsFBkiWNybn7edlq5R4MQBrxWknfgwfc1DjbFMjYgbMNCQqzgHHf43eKup6Cun3
rRFo1m0flF0j/FSbHWIely/IZ/bsBEVKwFTRoQjgrpEJDqm79Eu6XVe6kdVGXg==
=FCdT
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

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

To respond to this issue using the mumi CLI, first switch to it
mumi current 76289
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
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help