From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: 53676@debbugs.gnu.org
Subject: [bug#53676] [PATCH 4/5] services: pulseaudio: Add an extra-script-files configuration field.
Date: Sun, 06 Feb 2022 09:02:22 +0100 [thread overview]
Message-ID: <a2e2f7316c3c71d31897f416d8a68f4fa859ee56.camel@gmail.com> (raw)
In-Reply-To: <87czk01mp8.fsf@gmail.com>
Hi Maxim,
Am Sonntag, dem 06.02.2022 um 02:25 -0500 schrieb Maxim Cournoyer:
> 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.
Note that file-like->name serves multiple duties here. In my opinion
it'd be better to
--8<---------------cut here---------------start------------->8---
(define (file-like-name file)
((match file
((? local-file?) local-file-name)
((? plain-file?) plain-file-name)
((? computed-file?) computed-file-name)
[...]
(_ (const #f))) ; alternatively raise an error
file))
--8<---------------cut here---------------end--------------->8---
That at least decouples it from the burden of having to check whether
it is a valid pulseaudio script file name, which makes it reusable
elsewhere. As a note regarding correctness, perhaps we should write an
implementation in (guix gexp) that works for everything that has a
gexp-compiler, but that's out of scope for now.
On the pulseaudio side, you'd compose that with an
--8<---------------cut here---------------start------------->8---
(define (assert-pulseaudio-script-file-name name)
(unless name (raise ...))
(unless (string-suffix? name ".pa") (leave ...))
name)
--8<---------------cut here---------------end--------------->8---
Cheers
next prev parent reply other threads:[~2022-02-06 8:03 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-01 4:13 [bug#53676] [PATCH 0/5] *** PulseAudio service improvements *** Maxim Cournoyer
2022-02-01 4:19 ` [bug#53676] [PATCH 1/5] doc: Fix typo Maxim Cournoyer
2022-02-01 4:19 ` [bug#53676] [PATCH 2/5] services/sound: Normalize pulseaudio-configuration accessor names Maxim Cournoyer
2022-02-01 19:48 ` Liliana Marie Prikler
2022-02-01 20:18 ` Maxim Cournoyer
2022-02-01 21:29 ` Liliana Marie Prikler
2022-02-01 4:19 ` [bug#53676] [PATCH 3/5] gnu: pulseaudio: Graft to adjust configuration Maxim Cournoyer
2022-02-01 19:45 ` Liliana Marie Prikler
2022-02-01 20:20 ` Maxim Cournoyer
2022-02-01 21:37 ` Liliana Marie Prikler
2022-02-02 4:30 ` Maxim Cournoyer
2022-02-02 20:43 ` Liliana Marie Prikler
2022-02-06 6:30 ` [bug#53676] [PATCH 0/5] *** PulseAudio service improvements *** Maxim Cournoyer
2022-02-06 9:07 ` Liliana Marie Prikler
2022-02-24 16:31 ` Maxim Cournoyer
2022-02-24 20:26 ` Liliana Marie Prikler
2022-02-01 4:19 ` [bug#53676] [PATCH 4/5] services: pulseaudio: Add an extra-script-files configuration field Maxim Cournoyer
2022-02-01 19:56 ` Liliana Marie Prikler
2022-02-01 20:27 ` Maxim Cournoyer
2022-02-01 21:26 ` Liliana Marie Prikler
2022-02-02 3:44 ` Maxim Cournoyer
2022-02-02 20:07 ` Liliana Marie Prikler
2022-02-06 7:25 ` Maxim Cournoyer
2022-02-06 8:02 ` Liliana Marie Prikler [this message]
2022-02-24 16:25 ` Maxim Cournoyer
2022-02-01 4:19 ` [bug#53676] [PATCH 5/5] services: pulseaudio: Deploy the configuration files to /etc/pulse Maxim Cournoyer
2022-02-01 19:43 ` Liliana Marie Prikler
2022-02-02 22:43 ` Jack Hill
2022-02-07 22:29 ` [bug#53676] [PATCH 0/5] *** PulseAudio service improvements *** Maxim Cournoyer
2022-02-08 5:21 ` Liliana Marie Prikler
2022-02-08 14:25 ` Maxim Cournoyer
2022-02-08 19:31 ` Liliana Marie Prikler
2022-02-08 14:29 ` Maxim Cournoyer
2022-02-08 10:12 ` Maxime Devos
2022-02-08 14:27 ` Maxim Cournoyer
2022-02-24 16:36 ` Maxim Cournoyer
2022-02-24 14:42 ` [bug#53676] [PATCH 5/5] services: pulseaudio: Deploy the configuration files to /etc/pulse Maxim Cournoyer
2022-02-01 19:49 ` [bug#53676] [PATCH 1/5] doc: Fix typo Liliana Marie Prikler
2022-02-01 4:24 ` [bug#53676] [PATCH 0/5] *** PulseAudio service improvements *** Leo Famulari
2022-02-01 20:15 ` Maxim Cournoyer
2022-02-24 16:38 ` [bug#53676] [PATCH v2 1/4] services/sound: Normalize pulseaudio-configuration accessor names Maxim Cournoyer
2022-02-24 16:38 ` [bug#53676] [PATCH v2 2/4] gnu: pulseaudio: Graft to adjust configuration Maxim Cournoyer
2022-02-24 19:47 ` Liliana Marie Prikler
2022-02-24 22:00 ` Maxim Cournoyer
2022-02-25 5:20 ` Liliana Marie Prikler
2022-02-26 6:21 ` Maxim Cournoyer
2022-02-26 13:19 ` Liliana Marie Prikler
2022-02-26 14:14 ` bug#53676: " Maxim Cournoyer
2022-02-24 16:38 ` [bug#53676] [PATCH v2 3/4] services: pulseaudio: Add an extra-script-files configuration field Maxim Cournoyer
2022-02-24 18:53 ` Maxime Devos
2022-02-24 22:20 ` Maxim Cournoyer
2022-02-24 16:38 ` [bug#53676] [PATCH v2 4/4] services: pulseaudio: Deploy the configuration files to /etc/pulse Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2e2f7316c3c71d31897f416d8a68f4fa859ee56.camel@gmail.com \
--to=liliana.prikler@gmail.com \
--cc=53676@debbugs.gnu.org \
--cc=maxim.cournoyer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.