1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 21:20:33 +02:00

daemon: Implement ‘substitute-urls’ RPC.

* 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
This commit is contained in:
Ludovic Courtès
2023-11-10 21:37:28 +01:00
parent b650dcabf1
commit 1e47148f46
4 changed files with 58 additions and 7 deletions

View File

@@ -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<Strings>(str);
}
stopWork();
writeStrings(urls, to);
break;
}
default:
throw Error(format("invalid operation %1%") % op);
}