guix-patches
[Top][All Lists]
Advanced

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

[bug#71928] [PATCH] gnu: Throw error when extending services that do not


From: Richard Sent
Subject: [bug#71928] [PATCH] gnu: Throw error when extending services that do not use extensions.
Date: Wed, 3 Jul 2024 18:12:48 -0400

* 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






reply via email to

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