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

From: Maxime Devos <[email-masked]>
Date: Thu, 24 Feb 2022 19:53:34 +0100

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)))))))

Greetings,
Maxime.