GNU bug report logs - #53676
[PATCH 0/5] *** PulseAudio service improvements ***

Previous Next

Package: guix-patches;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Tue, 1 Feb 2022 04:15:02 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Cc: 53676 <at> debbugs.gnu.org
Subject: [bug#53676] [PATCH 4/5] services: pulseaudio: Add an extra-script-files configuration field.
Date: Sun, 06 Feb 2022 02:25:07 -0500
Hi Liliana,

[...]

>> 'strip-store-file-name' would be able to get the name from the store
>> item (built derivation), but file-union takes a "two-element list
>> where the first element is the file name to use in the new directory,
>> and the second element is a gexp denoting the target file", e.g.,
>> before the file-like object is built.  I don't see an easy way to
>> make it work.
> For the record, I do think we'd like to use file-like objects here, not
> raw gexps.  If that fails, why not expose the name to gexp mapping
> completely?  I don't know why you'd want to take away that control.

If we limit ourselves to file-like objects, we can do something like
this:

--8<---------------cut here---------------start------------->8---
1 file changed, 20 insertions(+), 4 deletions(-)
gnu/services/sound.scm | 24 ++++++++++++++++++++----

modified   gnu/services/sound.scm
@@ -26,10 +26,12 @@ (define-module (gnu services sound)
   #:use-module (gnu services)
   #:use-module (gnu system pam)
   #:use-module (gnu system shadow)
+  #:use-module (guix diagnostics)
   #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix records)
   #:use-module (guix store)
+  #:use-module (guix ui)
   #:use-module (gnu packages audio)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages pulseaudio)
@@ -149,10 +151,24 @@ (define pulseaudio-environment
        ("PULSE_CLIENTCONFIG" . "/etc/pulse/client.conf")))))
 
 (define (extra-script-files->file-union extra-script-files)
-  "Return a G-exp obtained by processing EXTRA-SCRIPT-FILES with FILE-UNION.
-Each file is named \"snippet-n.pa\", where N is their 1-offset index."
-  (let ((labels (map (lambda (n) (format #f "snippet-~a.pa" n))
-                     (iota (length extra-script-files) 1))))
+  "Return a G-exp obtained by processing EXTRA-SCRIPT-FILES with FILE-UNION."
+
+  (define (file-like->name file)
+    (let ((name (match file
+                  ((? local-file?)
+                   (local-file-name file))
+                  ((? plain-file?)
+                   (plain-file-name file))
+                  ((? computed-file?)
+                   (computed-file-name file))
+                  (_ (leave (G_ "~a is not a local-file, plain-file or \
+computed-file object~%") file)))))
+      (unless (string-suffix? name ".pa")
+        (leave (G_ "`~a' lacks the required '.pa' file name extension~%")
+               name))
+      name))
+
+  (let ((labels (map file-like->name extra-script-files)))
     (file-union "default.pa.d" (zip labels extra-script-files))))
 
 (define pulseaudio-etc
--8<---------------cut here---------------end--------------->8---

It works; and I agree it's nice to have control over the file name.

Maxim




This bug report was last modified 3 years and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.