guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#49812] [PATCH] services: In MODIFY-SERVICES macro allow specifying


From: Ludovic Courtès
Subject: [bug#49812] [PATCH] services: In MODIFY-SERVICES macro allow specifying a service by its name.
Date: Tue, 10 Aug 2021 16:23:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi,

Brice Waegeneire <brice@waegenei.re> skribis:

> This is specially useful with any services singleton created with
> 'simple-service' such as 'set-xorg-configuration'.

Could you show an example?  Services created by ‘simple-service’ &
co. are effectively anonymous; it’s a bit like a lambda.

> * doc/guix.texi (Service Reference)[modify-services]: Document support
>   for specifying service by its name.
> * gnu/services.scm (modify-services): Support specifying a service by
>   its name in addition to its type.

[...]

> +++ b/gnu/services.scm
> @@ -303,8 +303,9 @@ singleton service type NAME, of which the returned 
> service is an instance."
>           (%modify-service svc clauses ...)))
>      ((_ service)
>       service)
> -    ((_ svc (kind param => exp ...) clauses ...)
> -     (if (eq? (service-kind svc) kind)
> +    ((_ svc (kind-or-name param => exp ...) clauses ...)
> +     (if (or (eq? (service-kind svc) kind-or-name)                      ;kind
> +             (eq? (service-type-name (service-kind svc)) kind-or-name)) ;name

As a general design pattern in Guix, “names” (symbols) are here for UI
and/or debugging purposes; they should not be used elsewhere because, by
definition, names are ambiguous.  Conversely, object references are
unambiguous and non-forgeable, so I prefer interfaces that avoid “names”
entirely.

I hope that makes sense!

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]