GNU bug report logs - #49812
[PATCH] services: In MODIFY-SERVICES macro allow specifying a service by its name.

Previous Next

Package: guix-patches;

Reported by: Brice Waegeneire <brice <at> waegenei.re>

Date: Sun, 1 Aug 2021 21:04:02 UTC

Severity: normal

Tags: patch, wontfix

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49812 in the body.
You can then email your comments to 49812 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#49812; Package guix-patches. (Sun, 01 Aug 2021 21:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Brice Waegeneire <brice <at> waegenei.re>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 01 Aug 2021 21:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Brice Waegeneire <brice <at> waegenei.re>
To: guix-patches <at> gnu.org
Subject: [PATCH] services: In MODIFY-SERVICES macro allow specifying a service
 by its name.
Date: Sun,  1 Aug 2021 23:02:54 +0200
This is specially useful with any services singleton created with
'simple-service' such as 'set-xorg-configuration'.

* 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.
---
 doc/guix.texi    | 14 +++++++-------
 gnu/services.scm |  5 +++--
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 2298d512a1..3b50976358 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -34319,20 +34319,20 @@ standard list combinators such as @code{map} and @code{fold} to do that
 common pattern.
 
 @deffn {Scheme Syntax} modify-services @var{services} @
-  (@var{type} @var{variable} => @var{body}) @dots{}
+  (@var{type-or-name} @var{variable} => @var{body}) @dots{}
 
 Modify the services listed in @var{services} according to the given
 clauses.  Each clause has the form:
 
 @example
-(@var{type} @var{variable} => @var{body})
+(@var{type-or-name} @var{variable} => @var{body})
 @end example
 
-where @var{type} is a service type---e.g.,
-@code{guix-service-type}---and @var{variable} is an identifier that is
-bound within the @var{body} to the service parameters---e.g., a
-@code{guix-configuration} instance---of the original service of that
-@var{type}.
+where @var{type-or-name} is a service type or name---e.g.,
+@code{guix-service-type} or @code{'guix}---and @var{variable} is an
+identifier that is bound within the @var{body} to the service
+parameters---e.g., a @code{guix-configuration} instance---of the
+original service of that type.
 
 The @var{body} should evaluate to the new service parameters, which will
 be used to configure the new service.  This new service will replace the
diff --git a/gnu/services.scm b/gnu/services.scm
index 2a8114a219..736ad2e4b9 100644
--- a/gnu/services.scm
+++ 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
          (let ((param (service-value svc)))
            (service (service-kind svc)
                     (begin exp ...)))
-- 
2.32.0





Information forwarded to guix-patches <at> gnu.org:
bug#49812; Package guix-patches. (Tue, 10 Aug 2021 14:25:02 GMT) Full text and rfc822 format available.

Message #8 received at 49812 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Brice Waegeneire <brice <at> waegenei.re>
Cc: 49812 <at> debbugs.gnu.org
Subject: Re: bug#49812: [PATCH] services: In MODIFY-SERVICES macro allow
 specifying a service by its name.
Date: Tue, 10 Aug 2021 16:23:51 +0200
Hi,

Brice Waegeneire <brice <at> 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’.




Added tag(s) wontfix. Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 02 Jun 2023 14:21:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 49812 <at> debbugs.gnu.org and Brice Waegeneire <brice <at> waegenei.re> Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 02 Jun 2023 14:21:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 01 Jul 2023 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 293 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.