unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#71928] [PATCH] gnu: Throw error when extending services that do not use extensions.
@ 2024-07-03 22:12 Richard Sent
  2024-07-03 22:21 ` [bug#71928] [PATCH v2] " Richard Sent
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Sent @ 2024-07-03 22:12 UTC (permalink / raw)
  To: 71928; +Cc: Richard Sent

* gnu/services.scm (fold-services): Add error handling when using service
extensions.

Fixes: https://issues.guix.gnu.org/71887
Change-Id: Ic8d631674bfddde495c93952d9e6cd5649bb287d
---
 gnu/services.scm | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/gnu/services.scm b/gnu/services.scm
index 88593e8091..a7a9e00478 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -1223,12 +1223,22 @@ (define* (fold-services services
                      (params     -> (service-value sink))
                      (service
                       ->
-                      ;; Distinguish COMPOSE and EXTEND because PARAMS typically
-                      ;; has a different type than the elements of EXTENSIONS.
-                      (if extend
-                          (service (service-kind sink)
-                                   (extend params (compose extensions)))
-                          sink)))
+                      (begin
+                        (unless (or (null? extensions)
+                                    ;; A value of #t is a convention for "make
+                                    ;; sure the service is present."
+                                    (every (cut eq? #t <>) extensions)
+                                    (and extend compose))
+                          (error (format #f "Extensions are not supported in \
+~a yet the following service types extend it:~{~%   ~a~}"
+                                         (service-kind sink)
+                                         (map service-kind dependents))))
+                        ;; Distinguish COMPOSE and EXTEND because PARAMS typically
+                        ;; has a different type than the elements of EXTENSIONS.
+                        (if extend
+                            (service (service-kind sink)
+                                     (extend params (compose extensions)))
+                            sink))))
                   (mbegin %state-monad
                     (set-current-state (vhash-consq sink service visited))
                     (return service))))

base-commit: 85012e64819b39fd6112038134548b415fd5daff
-- 
2.45.2





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#71928] [PATCH v2] gnu: Throw error when extending services that do not use extensions.
  2024-07-03 22:12 [bug#71928] [PATCH] gnu: Throw error when extending services that do not use extensions Richard Sent
@ 2024-07-03 22:21 ` Richard Sent
  2024-09-30 20:43   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Sent @ 2024-07-03 22:21 UTC (permalink / raw)
  To: 71928; +Cc: Richard Sent

* gnu/services.scm (fold-services): Add error handling when using service
extensions.

Fixes: https://issues.guix.gnu.org/71887
Change-Id: Ic8d631674bfddde495c93952d9e6cd5649bb287d
---
 gnu/services.scm | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/gnu/services.scm b/gnu/services.scm
index 88593e8091..f3a1041f14 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -53,6 +53,7 @@ (define-module (gnu services)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
   #:use-module (srfi srfi-71)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
   #:autoload   (ice-9 pretty-print) (pretty-print)
@@ -1223,12 +1224,22 @@ (define* (fold-services services
                      (params     -> (service-value sink))
                      (service
                       ->
-                      ;; Distinguish COMPOSE and EXTEND because PARAMS typically
-                      ;; has a different type than the elements of EXTENSIONS.
-                      (if extend
-                          (service (service-kind sink)
-                                   (extend params (compose extensions)))
-                          sink)))
+                      (begin
+                        (unless (or (null? extensions)
+                                    ;; A value of #t is a convention for "make
+                                    ;; sure the service is present."
+                                    (every (cut eq? #t <>) extensions)
+                                    (and extend compose))
+                          (error (format #f "Extensions are not supported in \
+~a yet the following service types extend it:~{~%   ~a~}"
+                                         (service-kind sink)
+                                         (map service-kind dependents))))
+                        ;; Distinguish COMPOSE and EXTEND because PARAMS typically
+                        ;; has a different type than the elements of EXTENSIONS.
+                        (if extend
+                            (service (service-kind sink)
+                                     (extend params (compose extensions)))
+                            sink))))
                   (mbegin %state-monad
                     (set-current-state (vhash-consq sink service visited))
                     (return service))))

base-commit: 85012e64819b39fd6112038134548b415fd5daff
-- 
2.45.2





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#71928] [PATCH v2] gnu: Throw error when extending services that do not use extensions.
  2024-07-03 22:21 ` [bug#71928] [PATCH v2] " Richard Sent
@ 2024-09-30 20:43   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2024-09-30 20:43 UTC (permalink / raw)
  To: Richard Sent; +Cc: 71928

Hello,

Richard Sent <richard@freakingpenguin.com> skribis:

> * gnu/services.scm (fold-services): Add error handling when using service
> extensions.
>
> Fixes: https://issues.guix.gnu.org/71887
> Change-Id: Ic8d631674bfddde495c93952d9e6cd5649bb287d

[...]

> @@ -1223,12 +1224,22 @@ (define* (fold-services services
>                       (params     -> (service-value sink))
>                       (service
>                        ->
> -                      ;; Distinguish COMPOSE and EXTEND because PARAMS typically
> -                      ;; has a different type than the elements of EXTENSIONS.
> -                      (if extend
> -                          (service (service-kind sink)
> -                                   (extend params (compose extensions)))
> -                          sink)))
> +                      (begin
> +                        (unless (or (null? extensions)
> +                                    ;; A value of #t is a convention for "make
> +                                    ;; sure the service is present."
> +                                    (every (cut eq? #t <>) extensions)
> +                                    (and extend compose))
> +                          (error (format #f "Extensions are not supported in \
> +~a yet the following service types extend it:~{~%   ~a~}"
> +                                         (service-kind sink)
> +                                         (map service-kind dependents))))
> +                        ;; Distinguish COMPOSE and EXTEND because PARAMS typically
> +                        ;; has a different type than the elements of EXTENSIONS.
> +                        (if extend
> +                            (service (service-kind sink)
> +                                     (extend params (compose extensions)))
> +                            sink))))

I understand the current situation where extensions to a non-extensible
service are silently swallowed is suboptimal, but I wonder about the
implications of the semantic change here.

Currently the “#t means ensure the service is present” convention is not
enforced; is it even widely followed in the Guix repo?  But then, what
about repos out there that provide services?

It would seem to me that this is something that cannot be changed
overnight without running the risk to break people’s code.  So perhaps
the first step (and maybe last step?) would be to print a warning.

WDYT?

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-30 21:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-03 22:12 [bug#71928] [PATCH] gnu: Throw error when extending services that do not use extensions Richard Sent
2024-07-03 22:21 ` [bug#71928] [PATCH v2] " Richard Sent
2024-09-30 20:43   ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).