all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: 71887@debbugs.gnu.org
Subject: bug#71887: Raise an error when extending a service type that doesn't support extensions
Date: Mon, 01 Jul 2024 23:36:29 -0400	[thread overview]
Message-ID: <87cynwbh36.fsf@freakingpenguin.com> (raw)
In-Reply-To: <877ce4dar0.fsf@freakingpenguin.com> (Richard Sent's message of "Mon, 01 Jul 2024 18:10:27 -0400")

I've started looking into this issue and came up with the following
diff:

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/services.scm b/gnu/services.scm
index 88593e8091..e7e2da6ad5 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -1225,10 +1225,17 @@ (define* (fold-services services
                       ->
                       ;; Distinguish COMPOSE and EXTEND because PARAMS typically
                       ;; has a different type than the elements of EXTENSIONS.
-                      (if extend
+                      (begin
+                        (unless (or (null? extensions)
+                                    (and extend compose))
+                          (error (format #f "Extensions are not supported in ~a \
+yet the following extensions were found: ~a~%"
+                                         (service-kind sink)
+                                         dependents)))
+                        (if extend
                           (service (service-kind sink)
                                    (extend params (compose extensions)))
-                          sink)))
+                          sink))))
                   (mbegin %state-monad
                     (set-current-state (vhash-consq sink service visited))
                     (return service))))
--8<---------------cut here---------------end--------------->8---

Unfortunately this approach isn't sufficient. In certain cases services
intentionally extend other services to ensure they're instantiated even
when the service is unused. For example,

--8<---------------cut here---------------start------------->8---
(define cgit-service-type
  (service-type
   (name 'cgit)
   (extensions
    (list ...
          ;; Make sure fcgiwrap is instantiated.
          (service-extension fcgiwrap-service-type
                             (const #t))))
   ...
   (default-value (cgit-configuration))))
--8<---------------cut here---------------end--------------->8---

If we all agree that "make sure X is instantiated" service-extensions
must use (const #t), then the above diff can work with minimal
modifications (if every extension value is #t, valid). I'll see if I can
find where to document this when I create the full patch.

If not, I do not believe this bug is solvable. Any service can be
extended with any value regardless of whether that value is used or
coherent. Ergo there's no way to check if any particular extension is
valid.

$ make check-system TESTS=cgit is a good way to verify behavior in this
context.

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.




      reply	other threads:[~2024-07-02  3:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 22:10 bug#71887: Raise an error when extending a service type that doesn't support extensions Richard Sent
2024-07-02  3:36 ` Richard Sent [this message]

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

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

  git send-email \
    --in-reply-to=87cynwbh36.fsf@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=71887@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.