From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OC3qAIgHyl9QPwAA0tVLHw (envelope-from ) for ; Fri, 04 Dec 2020 09:55:20 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id kI1KOIcHyl+RfwAAB5/wlQ (envelope-from ) for ; Fri, 04 Dec 2020 09:55:19 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9B894940111 for ; Fri, 4 Dec 2020 09:55:19 +0000 (UTC) Received: from localhost ([::1]:47940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kl7o6-0007hu-Jm for larch@yhetil.org; Fri, 04 Dec 2020 04:55:18 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.79 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 9B894940111 X-Spam-Score: -1.79 X-Migadu-Scanner: ns3122888.ip-94-23-21.eu X-TUID: VWx8hexnxneB * 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 -- 2.29.2