Subject: Re: [bug#67598] [PATCH] gnu: services: guix: Allow gexps evaluating to a list of build-machines

From: Ludovic Courtès <[email-masked]>
Date: Sun, 10 Dec 2023 22:18:39 +0100

Hi,

Saku Laesvuori <[email-masked]> skribis:

> * gnu/services/base.scm (guix-machines-files-installation): Handle
> machines being a mixed list of build-machines and lists of
> build-machines.
> * doc/guix.texi: Document it.
>
> Change-Id: Ie404562ca0b564413233c3a624046da831893dc3

Sounds useful!

>  (guix-configuration
>    (build-machines
>      (list #~(build-machine (name "foo.example.org") @dots{})
> -          #~(build-machine (name "bar.example.org") @dots{}))))
> +          #~(list (build-machine (name "bar.example.org") @dots{})
> +                  (build-machine (name "foobaz.example.org") @dots{})))))

I wouldn’t show both in the same example as it can be confusing.  So
either leave the example unchanged or add a second one (maybe with
‘guix-extension’?).

> +        (symlink #+(scheme-file "machines.scm"
> +                                `(apply append

Use ‘concatenate’ instead, and #~ instead of `.

> +                                        (map (lambda (entry)
> +                                               (if (list? entry)
> +                                                 entry
> +                                                 (list entry)))
> +                                             ,machines)))

Since ‘list?’ is linear in the number of elements in the list, my
preference would be to write it like this:

  (if (build-machine? entry)
      (list entry)
      entry)

Could you send an updated patch?

Thanks,
Ludo’.