GNU bug report logs - #45040
[PATCH] service: Add shepherd discover action.

Previous Next

Package: guix-patches;

Reported by: Mathieu Othacehe <othacehe <at> gnu.org>

Date: Fri, 4 Dec 2020 09:55:02 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <othacehe <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 45040 in the body.
You can then email your comments to 45040 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#45040; Package guix-patches. (Fri, 04 Dec 2020 09:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mathieu Othacehe <othacehe <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 04 Dec 2020 09:55:02 GMT) Full text and rfc822 format available.

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

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: guix-patches <at> gnu.org
Cc: Mathieu Othacehe <othacehe <at> gnu.org>
Subject: [PATCH] service: Add shepherd discover action.
Date: Fri,  4 Dec 2020 10:54:17 +0100
* gnu/services/base.scm (shepherd-discover-action): New procedure,
(guix-shepherd-service)[<actions>]: add it,
[<start>]: honor it.
* doc/guix.texi (Invoking guix-daemon): Document it.
---
 doc/guix.texi         |  8 ++++++++
 gnu/services/base.scm | 32 ++++++++++++++++++++++++++++----
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 1493c68e27..4fc1dffe98 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -1602,6 +1602,14 @@ Servers may serve substitute over HTTP, unencrypted, so anyone on the
 LAN can see what software you’re installing.
 @end enumerate
 
+It is also possible to enable or disable substitute servers discovery at
+run-time by running:
+
+@example
+herd discover guix-daemon on
+herd discover guix-daemon off
+@end example
+
 @item --disable-deduplication
 @cindex deduplication
 Disable automatic file ``deduplication'' in the store.
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index d0d88e18a6..709d011f53 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -1568,6 +1568,27 @@ proxy of 'guix-daemon'...~%")
                     (environ environment)
                     #t)))))
 
+(define shepherd-discover-action
+  ;; Shepherd action to enable or disable substitute servers discovery.
+  (shepherd-action
+   (name 'discover)
+   (documentation
+    "Enable or disable substitute servers discovery and restart the
+'guix-daemon'.")
+   (procedure #~(lambda* (_ status)
+                  (let ((environment (environ)))
+                    (if (and status
+                             (string=? status "on"))
+                        (begin
+                          (format #t "enable substitute servers discovery~%")
+                          (setenv "discover" "on"))
+                        (begin
+                          (format #t "disable substitute servers discovery~%")
+                          (unsetenv "discover")))
+                    (action 'guix-daemon 'restart)
+                    (environ environment)
+                    #t)))))
+
 (define (guix-shepherd-service config)
   "Return a <shepherd-service> for the Guix daemon service with CONFIG."
   (match-record config <guix-configuration>
@@ -1579,7 +1600,8 @@ proxy of 'guix-daemon'...~%")
            (documentation "Run the Guix daemon.")
            (provision '(guix-daemon))
            (requirement '(user-processes))
-           (actions (list shepherd-set-http-proxy-action))
+           (actions (list shepherd-set-http-proxy-action
+                          shepherd-discover-action))
            (modules '((srfi srfi-1)
                       (ice-9 match)
                       (gnu build shepherd)))
@@ -1594,6 +1616,9 @@ proxy of 'guix-daemon'...~%")
                     ;; the 'set-http-proxy' action.
                     (or (getenv "http_proxy") #$http-proxy))
 
+                  (define discover?
+                    (or (getenv "discover") #$discover?))
+
                   ;; Start the guix-daemon from a container, when supported,
                   ;; to solve an installation issue. See the comment below for
                   ;; more details.
@@ -1608,9 +1633,8 @@ proxy of 'guix-daemon'...~%")
                           #$@(if use-substitutes?
                                  '()
                                  '("--no-substitutes"))
-                          #$@(if discover?
-                                 '("--discover=yes")
-                                 '())
+                          (string-append "--discover="
+                                         (if discover? "yes" "no"))
                           "--substitute-urls" #$(string-join substitute-urls)
                           #$@extra-options
 
-- 
2.29.2





Information forwarded to guix-patches <at> gnu.org:
bug#45040; Package guix-patches. (Sun, 06 Dec 2020 22:15:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Mathieu Othacehe <othacehe <at> gnu.org>
Cc: 45040 <at> debbugs.gnu.org
Subject: Re: [bug#45040] [PATCH] service: Add shepherd discover action.
Date: Sun, 06 Dec 2020 23:14:11 +0100
Hi!

Mathieu Othacehe <othacehe <at> gnu.org> skribis:

> * gnu/services/base.scm (shepherd-discover-action): New procedure,
> (guix-shepherd-service)[<actions>]: add it,
> [<start>]: honor it.
> * doc/guix.texi (Invoking guix-daemon): Document it.

[...]

> +It is also possible to enable or disable substitute servers discovery at

s/servers/server/

> +run-time by running:
> +
> +@example
> +herd discover guix-daemon on
> +herd discover guix-daemon off

Should it be “discovery” instead of “discover”?  Hmm…

Anyway, LGTM!

Thanks,
Ludo’.




Reply sent to Mathieu Othacehe <othacehe <at> gnu.org>:
You have taken responsibility. (Mon, 07 Dec 2020 09:43:02 GMT) Full text and rfc822 format available.

Notification sent to Mathieu Othacehe <othacehe <at> gnu.org>:
bug acknowledged by developer. (Mon, 07 Dec 2020 09:43:02 GMT) Full text and rfc822 format available.

Message #13 received at 45040-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 45040-done <at> debbugs.gnu.org
Subject: Re: [bug#45040] [PATCH] service: Add shepherd discover action.
Date: Mon, 07 Dec 2020 10:42:12 +0100
Hey,

> s/servers/server/

Fixed!

>> +run-time by running:
>> +
>> +@example
>> +herd discover guix-daemon on
>> +herd discover guix-daemon off
>
> Should it be “discovery” instead of “discover”?  Hmm…

The guix-daemon option is called "discover" so I would keep it that way,
but I also hesitated.

Pushed as e461d3b750080b03f3deea0b44b99c2fda9767ab.

Thanks for reviewing,

Mathieu




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 04 Jan 2021 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 112 days ago.

Previous Next


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