Subject: [bug#53676] [PATCH v2 3/4] services: pulseaudio: Add an extra-script-files configuration field.

From: Maxim Cournoyer <[email-masked]>
Date: Thu, 24 Feb 2022 17:20:48 -0500

Hi Maxime,

Maxime Devos <[email-masked]> writes:

> Maxim Cournoyer schreef op do 24-02-2022 om 11:38 [-0500]:
>> +  (define (file-like->name file)
>> +    (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))))
>
> This would not work with things like '(file-append ...)'.
> Perhaps 'extra-script-files->file-union' can be made more general
> by creating a variant of 'file-union' for this use case?
> Maybe something like (untested):
>
> ;; Based on 'file-union'
> (define* (file-directory . files)
>   ; files: (file-like1 file-like2 ...)
>   (computed-file name
>                  (with-imported-modules '((guix build utils))
>                    (gexp
>                     (begin
>                       (use-modules (guix build utils))
>
>                       (mkdir (ungexp output))
>                       (chdir (ungexp output))
>                       (ungexp-splicing
>                        (map (lambda (source)
>                               (gexp
>                                (let ((target (basename source))
>                                  ;; Stat the source to abort early if it does
>                                  ;; not exist.
>                                  (stat (ungexp source))
>                                  (symlink (ungexp source) (ungexp target)))))
>                             files)))))))

Not a bad idea, but it steers a bit on the too-complicated side of
things for my taste; for one thing, I wouldn't know how to do the
validation of the file name anymore (it needs to end by ".pa").  It
could be done inside that procedure, but it'd become more tangled.

The simple file-like->name procedure above will error with an accurate
message telling the users about its limits (that it only accepts
local-file, plain-file or computed-file).

G-Exp wizards can still opt the mixed-text-file + any G-Exp
transformation they wish via the 'script-file' field.

Thanks,

Maxim