unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: 71928@debbugs.gnu.org
Cc: Richard Sent <richard@freakingpenguin.com>
Subject: [bug#71928] [PATCH] gnu: Throw error when extending services that do not use extensions.
Date: Wed,  3 Jul 2024 18:12:48 -0400	[thread overview]
Message-ID: <e556c70340d5cda9b87852e137722d082f093c10.1720044768.git.richard@freakingpenguin.com> (raw)

* 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	other threads:[~2024-07-03 22:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 22:12 Richard Sent [this message]
2024-07-03 22:21 ` [bug#71928] [PATCH v2] gnu: Throw error when extending services that do not use extensions Richard Sent
2024-09-30 20:43   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e556c70340d5cda9b87852e137722d082f093c10.1720044768.git.richard@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=71928@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).