From patchwork Fri Dec 4 09:54:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 25564 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 57D6B27BBFE; Fri, 4 Dec 2020 09:55:19 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 84B2527BBFC for ; Fri, 4 Dec 2020 09:55:18 +0000 (GMT) Received: from localhost ([::1]:47940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kl7o5-0007hu-Od for patchwork@mira.cbaines.net; Fri, 04 Dec 2020 04:55:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kl7nr-0007gH-Bq for guix-patches@gnu.org; Fri, 04 Dec 2020 04:55:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:59457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kl7nq-0000sw-CR for guix-patches@gnu.org; Fri, 04 Dec 2020 04:55:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kl7nq-00027f-7C for guix-patches@gnu.org; Fri, 04 Dec 2020 04:55:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45040] [PATCH] service: Add shepherd discover action. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 04 Dec 2020 09:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45040 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45040@debbugs.gnu.org Cc: Mathieu Othacehe X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16070756748020 (code B ref -1); Fri, 04 Dec 2020 09:55:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Dec 2020 09:54:34 +0000 Received: from localhost ([127.0.0.1]:42735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kl7nN-00025I-PT for submit@debbugs.gnu.org; Fri, 04 Dec 2020 04:54:34 -0500 Received: from lists.gnu.org ([209.51.188.17]:40998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kl7nM-000259-4t for submit@debbugs.gnu.org; Fri, 04 Dec 2020 04:54:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kl7nL-0007Cm-SH for guix-patches@gnu.org; Fri, 04 Dec 2020 04:54:31 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34765) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kl7nK-0000eZ-GD for guix-patches@gnu.org; Fri, 04 Dec 2020 04:54:31 -0500 Received: from [2a01:e0a:19b:d9a0:ec50:e664:fea6:2900] (port=35040 helo=localhost.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kl7nJ-0004eG-5Y; Fri, 04 Dec 2020 04:54:29 -0500 From: Mathieu Othacehe Date: Fri, 4 Dec 2020 10:54:17 +0100 Message-Id: <20201204095417.195976-1-othacehe@gnu.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/base.scm (shepherd-discover-action): New procedure, (guix-shepherd-service)[]: add it, []: 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 for the Guix daemon service with CONFIG." (match-record config @@ -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