From patchwork Mon Dec 4 14:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 57285 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 4B0C427BBEA; Mon, 4 Dec 2023 14:17:07 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1210C27BBE9 for ; Mon, 4 Dec 2023 14:17:06 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rA9ko-0006iU-2N; Mon, 04 Dec 2023 09:16:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rA9km-0006eJ-3y for guix-patches@gnu.org; Mon, 04 Dec 2023 09:16:56 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rA9kl-0007XW-ON; Mon, 04 Dec 2023 09:16:55 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rA9ks-0007gH-Ou; Mon, 04 Dec 2023 09:17:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67072] [PATCH v2 1/4] daemon: Implement =?utf-8?b?4oCYc3Vic3Rp?= =?utf-8?b?dHV0ZS11cmxz4oCZ?= RPC. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 04 Dec 2023 14:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67072 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67072@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 67072-submit@debbugs.gnu.org id=B67072.170169939429444 (code B ref 67072); Mon, 04 Dec 2023 14:17:02 +0000 Received: (at 67072) by debbugs.gnu.org; 4 Dec 2023 14:16:34 +0000 Received: from localhost ([127.0.0.1]:33758 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rA9kQ-0007ep-0T for submit@debbugs.gnu.org; Mon, 04 Dec 2023 09:16:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rA9kJ-0007eE-Pt for 67072@debbugs.gnu.org; Mon, 04 Dec 2023 09:16:32 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rA9k3-0007R6-NF; Mon, 04 Dec 2023 09:16:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=vMkh5C3ITAbYbJg+zrJaPIcm3yJ3i9tj9YvrYjFzorY=; b=ExZ5d7tn+NMgyBvrQfEr zMBYFUVHMkbHoLrMpSUkn8JmuhJblpj/HNrebIvWTjNJYBMqym/zrsNBnHuKLNrOaA9FZpchjKF+A yag4cWEo+vrjkYf3eVhGw/UNU8V8rQ1iIo9j50IQJSw3Dfl7yuLxIZ7Sh3aY6bpW2ceNelbw/Zzac 6Qz738T4d1hsCZAG9G3kqPZtcT1mNvSBM5ua2oeeW8UfwQ9FxwPhjTxc52NJqHBBNTHs0h0dRzmLw ArehiDSdo09FZ5/ff91w7f8wlWTBBi8COhFnWHkJy+/wXpqLaHtDeHRH4FqCeKHeBzkt9JtQJGys1 yc+WHDhS8K8FRw==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 4 Dec 2023 15:15:42 +0100 Message-ID: <22d2093841b549484a8c5c03207ec3c34a01f7e0.1701699075.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <875y1gj47u.fsf@gnu.org> References: <875y1gj47u.fsf@gnu.org> 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump. (WorkerOp): Add ‘wopSubstituteURLs’. * nix/nix-daemon/nix-daemon.cc (performOp): Implement it. * guix/store.scm (%protocol-version): Bump. (operation-id): Add ‘substitute-urls’. (substitute-urls): New procedure. * tests/store.scm ("substitute-urls, default") ("substitute-urls, client-specified URLs") ("substitute-urls, disabled"): New tests. Change-Id: I2c0119500c3a1eecfa5ebf32463ffb0f173161de --- guix/store.scm | 18 +++++++++++++++--- nix/libstore/worker-protocol.hh | 5 +++-- nix/nix-daemon/nix-daemon.cc | 17 +++++++++++++++++ tests/store.scm | 25 +++++++++++++++++++++++-- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/guix/store.scm b/guix/store.scm index f8e77b2cd9..97c4f32a5b 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012-2022 Ludovic Courtès +;;; Copyright © 2012-2023 Ludovic Courtès ;;; Copyright © 2018 Jan Nieuwenhuizen ;;; Copyright © 2019, 2020 Mathieu Othacehe ;;; Copyright © 2020 Florian Pelz @@ -145,6 +145,7 @@ (define-module (guix store) path-info-nar-size built-in-builders + substitute-urls references references/cached references* @@ -199,7 +200,7 @@ (define-module (guix store) derivation-log-file log-file)) -(define %protocol-version #x163) +(define %protocol-version #x164) (define %worker-magic-1 #x6e697863) ; "nixc" (define %worker-magic-2 #x6478696f) ; "dxio" @@ -253,7 +254,8 @@ (define-enumerate-type operation-id (query-valid-derivers 33) (optimize-store 34) (verify-store 35) - (built-in-builders 80)) + (built-in-builders 80) + (substitute-urls 81)) (define-enumerate-type hash-algo ;; hash.hh @@ -1780,6 +1782,16 @@ (define-operation (clear-failed-paths (store-path-list items)) This makes sense only when the daemon was started with '--cache-failures'." boolean) +(define substitute-urls + (let ((urls (operation (substitute-urls) + #f + string-list))) + (lambda (store) + "Return the list of currently configured substitutes URLs for STORE, or +#f if the daemon is too old and does not implement this RPC." + (and (>= (store-connection-version store) #x164) + (urls store))))) + ;;; ;;; Per-connection caches. diff --git a/nix/libstore/worker-protocol.hh b/nix/libstore/worker-protocol.hh index ea67b10a5b..ef259db2a0 100644 --- a/nix/libstore/worker-protocol.hh +++ b/nix/libstore/worker-protocol.hh @@ -6,7 +6,7 @@ namespace nix { #define WORKER_MAGIC_1 0x6e697863 #define WORKER_MAGIC_2 0x6478696f -#define PROTOCOL_VERSION 0x163 +#define PROTOCOL_VERSION 0x164 #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00) #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff) @@ -44,7 +44,8 @@ typedef enum { wopQueryValidDerivers = 33, wopOptimiseStore = 34, wopVerifyStore = 35, - wopBuiltinBuilders = 80 + wopBuiltinBuilders = 80, + wopSubstituteURLs = 81 } WorkerOp; diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index 497de11a04..4cb05c802e 100644 --- a/nix/nix-daemon/nix-daemon.cc +++ b/nix/nix-daemon/nix-daemon.cc @@ -736,6 +736,23 @@ static void performOp(bool trusted, unsigned int clientVersion, break; } + case wopSubstituteURLs: { + startWork(); + Strings urls; + if (settings.get("build-use-substitutes", std::string("false")) == "true") { + /* First check the client-provided substitute URLs, then those + passed to the daemon. */ + auto str = settings.get("untrusted-substitute-urls", std::string("")); + if (str.empty()) { + str = settings.get("substitute-urls", std::string("")); + } + urls = tokenizeString(str); + } + stopWork(); + writeStrings(urls, to); + break; + } + default: throw Error(format("invalid operation %1%") % op); } diff --git a/tests/store.scm b/tests/store.scm index 5df28adf0d..45948f4f43 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2012-2021, 2023 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -105,7 +105,28 @@ (define %shell "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7/bin/guile"))) (not (direct-store-path? (%store-prefix))))) -(test-skip (if %store 0 15)) +(test-skip (if %store 0 18)) + +(test-equal "substitute-urls, default" + (list (getenv "GUIX_BINARY_SUBSTITUTE_URL")) + (with-store store + (set-build-options store #:use-substitutes? #t) + (substitute-urls store))) + +(test-equal "substitute-urls, client-specified URLs" + '("http://substitutes.example.org" + "http://other.example.org") + (with-store store + (set-build-options store #:use-substitutes? #t + #:substitute-urls '("http://substitutes.example.org" + "http://other.example.org")) + (substitute-urls store))) + +(test-equal "substitute-urls, disabled" + '() + (with-store store + (set-build-options store #:use-substitutes? #f) + (substitute-urls store))) (test-equal "profiles/per-user exists and is not writable" #o755 From patchwork Mon Dec 4 14:15:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 57288 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 168BA27BBE9; Mon, 4 Dec 2023 14:17:42 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6786127BBE2 for ; Mon, 4 Dec 2023 14:17:41 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rA9kr-0006jK-9b; Mon, 04 Dec 2023 09:17:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rA9kl-0006eD-6q for guix-patches@gnu.org; Mon, 04 Dec 2023 09:16:56 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rA9kk-0007Wx-6S; Mon, 04 Dec 2023 09:16:54 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rA9kt-0007gT-6b; Mon, 04 Dec 2023 09:17:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67072] [PATCH v2 2/4] challenge: Use the same substitute URLs as guix-daemon. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 04 Dec 2023 14:17:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67072 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67072@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 67072-submit@debbugs.gnu.org id=B67072.170169939729453 (code B ref 67072); Mon, 04 Dec 2023 14:17:03 +0000 Received: (at 67072) by debbugs.gnu.org; 4 Dec 2023 14:16:37 +0000 Received: from localhost ([127.0.0.1]:33760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rA9kS-0007ez-U8 for submit@debbugs.gnu.org; Mon, 04 Dec 2023 09:16:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rA9kP-0007eP-AB for 67072@debbugs.gnu.org; Mon, 04 Dec 2023 09:16:33 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rA9k9-0007Ri-Dm; Mon, 04 Dec 2023 09:16:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=tr4GCLXY9vCKCXMkzWp2PiyLagQtaTOJotynNo9MsX0=; b=jdwSd5fvQt0peuaT99ZA oTMPNa7aThmnVcZkul0iGpfVO5NoH09xEpqCi0yMkxATd1j70oCysDTId4/UKcuOGkeJZ/nXRkBqP XAQ+hT9tAYPtyvDiExtN/z33/mUx47zX1MQlH2iPQwOsD5oH+Cng5rpmjpvnjp8LCyToO/rtL87Ej OUUm/9on0nw+aD1d2r+OfHkFLWV6y7si/at229+oEfs82yTGp3stfSBJzLAvJKJZqzrSerqBRIrdH QTnGWThQhPZof7xJGgGmN78m2RJUl0pgNBtnEsZSMbZ9IS8HnQEz/2EHhoqtlxgDHYfEbgz2kYJAo Vdd7JUJilPZsvg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 4 Dec 2023 15:15:43 +0100 Message-ID: <151b3401ea953f7d4af0c9c35ba6377468fe92b9.1701699075.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <875y1gj47u.fsf@gnu.org> References: <875y1gj47u.fsf@gnu.org> 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/challenge.scm (%default-options): Remove ‘substitute-urls’. (guix-challenge): Call ‘substitute-urls’ when OPTS doesn’t have it. Warn when ‘substitute-urls’ returns #f. Change-Id: I49be0e89404c1889970a3430967fbb3498d35d99 --- guix/scripts/challenge.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/guix/scripts/challenge.scm b/guix/scripts/challenge.scm index 01e2f9a2b2..d38171b868 100644 --- a/guix/scripts/challenge.scm +++ b/guix/scripts/challenge.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015-2017, 2019-2022 Ludovic Courtès +;;; Copyright © 2015-2017, 2019-2023 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -504,7 +504,6 @@ (define %options (define %default-options `((system . ,(%current-system)) - (substitute-urls . ,%default-substitute-urls) (difference-report . ,report-differing-files))) @@ -539,7 +538,13 @@ (define-command (guix-challenge . args) (G_ "no arguments specified, nothing to do~%")) (exit 0)) (x - files)))) + files))) + (urls (or urls + (substitute-urls store) + (begin + (warning (G_ "could not determine current \ +substitute URLs; using defaults~%")) + %default-substitute-urls)))) (set-build-options store #:use-substitutes? #f) From patchwork Mon Dec 4 14:15:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 57286 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 2054427BBE9; Mon, 4 Dec 2023 14:17:29 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 18DD827BBE2 for ; Mon, 4 Dec 2023 14:17:27 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rA9kp-0006ip-6y; Mon, 04 Dec 2023 09:16:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rA9kl-0006eB-5f for guix-patches@gnu.org; Mon, 04 Dec 2023 09:16:56 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rA9kk-0007Ww-5B; Mon, 04 Dec 2023 09:16:54 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rA9kt-0007gb-JT; Mon, 04 Dec 2023 09:17:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67072] [PATCH v2 3/4] weather: Use the same substitute URLs as guix-daemon. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 04 Dec 2023 14:17:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67072 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67072@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 67072-submit@debbugs.gnu.org id=B67072.170169940029468 (code B ref 67072); Mon, 04 Dec 2023 14:17:03 +0000 Received: (at 67072) by debbugs.gnu.org; 4 Dec 2023 14:16:40 +0000 Received: from localhost ([127.0.0.1]:33766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rA9kV-0007fE-FT for submit@debbugs.gnu.org; Mon, 04 Dec 2023 09:16:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52194) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rA9kT-0007ea-13 for 67072@debbugs.gnu.org; Mon, 04 Dec 2023 09:16:38 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rA9kB-0007TP-NZ; Mon, 04 Dec 2023 09:16:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=ZfGlG5r29Z9pXRIJGfGbJeOdLH7NNEOjDlwC65hUMe0=; b=I/yjcG4ZRGcWkhMEBtox 8Cs1ncmAYLHcMI0BMy0DkjGbKe3ZSO3DFHGcJCC7gQZSPxuqqeLSHFgWzQDmX9gfBIaPpjKT8aFb/ 90xBAAsMxJPG0bEEllx0Ed/LrfC66ynKO+kVHJynbeWhMJQyk86/TDnJNicTtYuWiyk45ftZnNyfW qCiy3zjTKSxnzCWIRcv47igVzW04W80NySz1cL70SMX35XiozVoUPrZhgGkgEIEMvZyr4UW/c3qxZ 93A49t/sy53h+TEwnPi5OmhaQsvBQGLRTjT6RpzMJPvX70M17Qtc+qj/Zrwi4WaQ03zaOPBfdfd2V l9qybyQUHZp7MQ==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 4 Dec 2023 15:15:44 +0100 Message-ID: <27ea9197f90933c2c53ebe57e1406c70f4a165ab.1701699075.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <875y1gj47u.fsf@gnu.org> References: <875y1gj47u.fsf@gnu.org> 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/weather.scm (%default-options): Remove ‘substitute-urls’. (guix-weather): Call ‘substitute-urls’ when OPTS doesn’t have it. Warn when ‘substitute-urls’ returns #f. * doc/guix.texi (Invoking guix weather): Adjust accordingly. Change-Id: I3e9100074f2ad559e5c408660db70430d64f2bef --- doc/guix.texi | 5 +++-- guix/scripts/weather.scm | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1fd2e21608..74739c5392 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16504,8 +16504,9 @@ Invoking guix weather @table @code @item --substitute-urls=@var{urls} @var{urls} is the space-separated list of substitute server URLs to -query. When this option is omitted, the default set of substitute -servers is queried. +query. When this option is omitted, the URLs specified with the +@option{--substitute-urls} option of @command{guix-daemon} are used or, +as a last resort, the default set of substitute URLs. @item --system=@var{system} @itemx -s @var{system} diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm index 140df3435f..7e302fcea7 100644 --- a/guix/scripts/weather.scm +++ b/guix/scripts/weather.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2017-2022 Ludovic Courtès +;;; Copyright © 2017-2023 Ludovic Courtès ;;; Copyright © 2017 Ricardo Wurmus ;;; Copyright © 2018 Kyle Meyer ;;; Copyright © 2020 Simon Tournier @@ -391,7 +391,7 @@ (define %options %standard-native-build-options)) (define %default-options - `((substitute-urls . ,%default-substitute-urls))) + '()) (define (load-manifest file) "Load the manifest from FILE and return the list of packages it refers to." @@ -582,7 +582,13 @@ (define-command (guix-weather . args) (let* ((opts (parse-command-line args %options (list %default-options) #:build-options? #f)) - (urls (assoc-ref opts 'substitute-urls)) + (urls (or (assoc-ref opts 'substitute-urls) + (with-store store + (substitute-urls store)) + (begin + (warning (G_ "could not determine current \ +substitute URLs; using defaults~%")) + %default-substitute-urls))) (systems (match (filter-map (match-lambda (('system . system) system) (_ #f)) From patchwork Mon Dec 4 14:15:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 57287 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 6D7EE27BBE2; Mon, 4 Dec 2023 14:17:29 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AC0E427BBEA for ; Mon, 4 Dec 2023 14:17:27 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rA9kn-0006gs-DL; Mon, 04 Dec 2023 09:16:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rA9kl-0006eG-VU for guix-patches@gnu.org; Mon, 04 Dec 2023 09:16:56 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rA9kl-0007XT-Jr; Mon, 04 Dec 2023 09:16:55 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rA9ku-0007gm-39; Mon, 04 Dec 2023 09:17:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67072] [PATCH v2 4/4] weather: Report unauthorized substitute servers. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 04 Dec 2023 14:17:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67072 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67072@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 67072-submit@debbugs.gnu.org id=B67072.170169941329501 (code B ref 67072); Mon, 04 Dec 2023 14:17:04 +0000 Received: (at 67072) by debbugs.gnu.org; 4 Dec 2023 14:16:53 +0000 Received: from localhost ([127.0.0.1]:33768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rA9kj-0007fk-4W for submit@debbugs.gnu.org; Mon, 04 Dec 2023 09:16:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rA9kT-0007eb-2O for 67072@debbugs.gnu.org; Mon, 04 Dec 2023 09:16:52 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rA9kD-0007Td-6T; Mon, 04 Dec 2023 09:16:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=V6nlTNYxN3hPiUhWN2/GPo/z97In72ac+nfAFwYN5Ak=; b=EewQNjCUvGEBD4K7zzxu gqAMWT2AGFCPTJfAXocBSmdTtQQMb62eDSYje7Bos0/4W6Su4m3PtZd1tOqx1pQh2gZOGbjbAUQfN SRrWuagPb7c17NzEsJlJTpC/A1v1ObGvTzzrAuJ8T8PYCIa9sfI8CB3FwRBND2fWZE3a1jcF0XfIU flWt35xepNj8ydGATX29ezsA5ZzkzhESU4lM9JvYRfYp13+AEEuT0TnymPFq0p2BwqfC5u0eDN0FM v0j/Wkc2yhbtqVSGa/wos8styP3XsWrgSgynBZXDh37La+r1dmJfbmMLM4h49D6wHkuDDbq0km/py IfdNFsXiDfz4Bg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 4 Dec 2023 15:15:45 +0100 Message-ID: <00a2a9b80cad49f9809c0c339349573bdf7d1b9c.1701699075.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <875y1gj47u.fsf@gnu.org> References: <875y1gj47u.fsf@gnu.org> 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches The goal is to make it easier to diagnose substitute misconfiguration (where we’re passing a substitute URL whose corresponding key is not authorized). Suggested by Emmanuel Agullo. * guix/scripts/weather.scm (check-narinfo-authorization): New procedure. (report-server-coverage): Use it. * doc/guix.texi (Invoking guix weather): Document it. (Getting Substitutes from Other Servers): Add “Troubleshooting” frame. Change-Id: I0a049c39eefb10d6a06634c8b16aa86902769791 --- doc/guix.texi | 21 +++++++++++++++- guix/scripts/weather.scm | 53 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 74739c5392..f1780df5a1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4058,6 +4058,7 @@ Substitute Server Authorization @node Getting Substitutes from Other Servers @subsection Getting Substitutes from Other Servers +@c Note: This section name appears in a hint printed by 'guix weather'. @cindex substitute servers, adding more Guix can look up and fetch substitutes from several servers. This is @@ -4157,6 +4158,21 @@ Getting Substitutes from Other Servers substitute lookup can be slowed down if too many servers need to be contacted. +@quotation Troubleshooting +To diagnose problems, you can run @command{guix weather}. For example, +running: + +@example +guix weather coreutils +@end example + +@noindent +not only tells you which of the currently-configured servers has +substitutes for the @code{coreutils} package, it also reports whether +one of these servers is unauthorized. @xref{Invoking guix weather}, for +more information. +@end quotation + Note that there are also situations where one may want to add the URL of a substitute server @emph{without} authorizing its key. @xref{Substitute Authentication}, to understand this fine point. @@ -16437,7 +16453,10 @@ Invoking guix weather specified servers so you can have an idea of whether you'll be grumpy today. It can sometimes be useful info as a user, but it is primarily useful to people running @command{guix publish} (@pxref{Invoking guix -publish}). +publish}). Sometimes substitutes @emph{are} available but they are not +authorized on your system; @command{guix weather} reports it so you can +authorize them if you want (@pxref{Getting Substitutes from Other +Servers}). @cindex statistics, for substitutes @cindex availability of substitutes diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm index 7e302fcea7..2f8985593d 100644 --- a/guix/scripts/weather.scm +++ b/guix/scripts/weather.scm @@ -35,6 +35,8 @@ (define-module (guix scripts weather) #:use-module ((guix build utils) #:select (every*)) #:use-module (guix substitutes) #:use-module (guix narinfo) + #:use-module (guix pki) + #:autoload (gcrypt pk-crypto) (canonical-sexp->string) #:use-module (guix http-client) #:use-module (guix ci) #:use-module (guix sets) @@ -185,6 +187,44 @@ (define (store-item-system store item) (() #f))) +(define (check-narinfo-authorization narinfo) + "Print a warning when NARINFO is not signed by an authorized key." + (define acl + (catch 'system-error + (lambda () + (current-acl)) + (lambda args + (warning (G_ "could not read '~a': ~a~%") + %acl-file (strerror (system-error-errno args))) + (warning (G_ "'~a' is unreadable, cannot determine whether \ +substitutes are authorized~%") + %acl-file) + #f))) + + (unless (or (not acl) (valid-narinfo? narinfo acl)) + (warning (G_ "substitutes from '~a' are unauthorized~%") + (narinfo-uri-base narinfo)) + ;; The "all substitutes" below reflects the fact that, in reality, it *is* + ;; possible to download "unauthorized" substitutes, as long as they match + ;; authorized substitutes. + (display-hint (G_ "To authorize all substitutes from @uref{~a} to be +downloaded, the following command needs to be run as root: + +@example +guix archive --authorize <string + (signature-subject (narinfo-signature narinfo)))))) + (define* (report-server-coverage server items #:key display-missing?) "Report the subset of ITEMS available as substitutes on SERVER. @@ -204,6 +244,12 @@ (define* (report-server-coverage server items #:make-progress-reporter (lambda* (total #:key url #:allow-other-keys) (progress-reporter/bar total))))) + (match narinfos + (() #f) + ((narinfo . _) + ;; Help diagnose missing substitute authorizations. + (check-narinfo-authorization narinfo))) + (let ((obtained (length narinfos)) (requested (length items)) (missing (lset-difference string=? @@ -586,8 +632,11 @@ (define-command (guix-weather . args) (with-store store (substitute-urls store)) (begin - (warning (G_ "could not determine current \ -substitute URLs; using defaults~%")) + ;; Could not determine the daemon's current + ;; substitute URLs, presumably because it's too + ;; old. + (warning (G_ "using default \ +substitute URLs~%")) %default-substitute-urls))) (systems (match (filter-map (match-lambda (('system . system) system)