From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IF6ABiRiT2U9ggAAauVa8A:P1 (envelope-from ) for ; Sat, 11 Nov 2023 12:14:44 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IF6ABiRiT2U9ggAAauVa8A (envelope-from ) for ; Sat, 11 Nov 2023 12:14:44 +0100 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 A6554541CF for ; Sat, 11 Nov 2023 12:14:43 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=lUU4wu7A; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1699701284; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=BhSTXMbeu4DBpw8CxXfbJ+NQdhUjNkSpK2bgYn6uSgs=; b=f/dO/22ceCZyyqBfrLzSSAVQhACSEZYnQ/SzVi5L3tqDLr/rZEvQDP5+fKI98e6LM82Iq8 qPSanXQEVU/Gq63KOZMPRlM47OVEuviMWq1rqCpwbXdxv8WDs3/BLOiimgNZAIr9HmWB02 xsvOGQk2qOXgT+RYxOozikMRRyiw0Ovy8XaOL/W3/uqkilqRsNDSLB2ZT72KkY1H4bSozd aOSBDnrGrj8qjuW5fJBGnKJBCPb+es8CifTusZl8+MVJ6ZRqpsA09miof9wqfowr8OBy34 Y3+me2ewhL6HQceLfQYxwjQIEubm53Ub6yqpBqUvRAy89MGObNdmGwZEWWtWnA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=lUU4wu7A; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1699701284; a=rsa-sha256; cv=none; b=s+wKeaR3/lQfnt+JFb3N+caipvi+oJ8L2XRGImxpLpL8VkdA1P626Ky8nzVCrK1DjVlPtQ rpQzDKyuOeXV4tbQVRB6VASg549bizoGuae1w/LCymD/+2DzJSp99HJkuEV7/hfyR8gcW1 7zP5aVUGLqu4u6qXf9gZhpzFVgz9gztBh0ya0Owal4Ld5qLCp1xaHnCtsXze41XVlk2LLk 6zjkDSD+9kjmrSnEQgNEAzoITNB1gbWCxmMsqzamPN0C91625wuDp2njNtZ/XetHw2ELfl fhPfU6ANIl/Q9rivSVo3C5/cu4igA3esuRLSmTsU6cwwlthy8T39bNzm2m9Hhw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1lwY-0004VV-Kg; Sat, 11 Nov 2023 06:14:26 -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 1r1lwW-0004Ub-G4 for guix-patches@gnu.org; Sat, 11 Nov 2023 06:14:24 -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 1r1lwW-0002FP-3r; Sat, 11 Nov 2023 06:14:24 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r1lx7-0005oS-Ri; Sat, 11 Nov 2023 06:15:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67072] [PATCH 1/4] daemon: Implement =?UTF-8?Q?=E2=80=98substitute-urls=E2=80=99?= 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: Sat, 11 Nov 2023 11:15:01 +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.169970126822261 (code B ref 67072); Sat, 11 Nov 2023 11:15:01 +0000 Received: (at 67072) by debbugs.gnu.org; 11 Nov 2023 11:14:28 +0000 Received: from localhost ([127.0.0.1]:52175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1lwZ-0005mz-Qh for submit@debbugs.gnu.org; Sat, 11 Nov 2023 06:14:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44194) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1lwU-0005mP-R7 for 67072@debbugs.gnu.org; Sat, 11 Nov 2023 06:14:26 -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 1r1lvk-00025r-DX; Sat, 11 Nov 2023 06:13:36 -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=lUU4wu7A3ioF1HFXX3NU xvE7Mz6Mt4kmvGRYn/w4noLK0S77y7lXlfVP+XQ6PkHozh2IJzeCD5pwOlhgNWSW8QKnGNFSL1GNR 3dvJVCNLjvZ5nVpT87V0EjmNDPu0o5V8aR2N6CItOzP9xlNCMTVIONSv8stz9gHK6D0bDoV/ikXaM ZCzFa6gyGk8Q9niI/mLN9r60mlTv4ovho9FIUg/m0aKgAAXIcz8ztJH4jc2mAv9PiDjQ9oLhIQ+tT dMPgK9a789Uhrmn+W/3eqY6IeF6B4yq0P/E4cDUx+ohn3Fu4eyVi64nPI8PtBb7yRhRe3eVHfShJG BLNq/XNGvisXww==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sat, 11 Nov 2023 12:06:23 +0100 Message-ID: <6ea1497c61199f29f816640c3f6923f3b57d0bbf.1699700049.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -4.31 X-Spam-Score: -4.31 X-Migadu-Queue-Id: A6554541CF X-Migadu-Scanner: mx13.migadu.com X-TUID: Ftd0AuqWvX2/ * 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 -- 2.41.0