diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2023-11-10 21:37:28 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2023-12-11 23:18:53 +0100 |
| commit | 1e47148f46e31eb99ce8ec7bc12232cf50d0ebec (patch) | |
| tree | a2693022e88bc939e32b47671f8464d3ec3d4df0 /nix | |
| parent | b650dcabf1cd1aa596228e1e7eff4acf372ef6a6 (diff) | |
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
Diffstat (limited to 'nix')
| -rw-r--r-- | nix/libstore/worker-protocol.hh | 5 | ||||
| -rw-r--r-- | nix/nix-daemon/nix-daemon.cc | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/nix/libstore/worker-protocol.hh b/nix/libstore/worker-protocol.hh index ea67b10a5be..ef259db2a01 100644 --- a/nix/libstore/worker-protocol.hh +++ b/nix/libstore/worker-protocol.hh | |||
| @@ -6,7 +6,7 @@ namespace nix { | |||
| 6 | #define WORKER_MAGIC_1 0x6e697863 | 6 | #define WORKER_MAGIC_1 0x6e697863 |
| 7 | #define WORKER_MAGIC_2 0x6478696f | 7 | #define WORKER_MAGIC_2 0x6478696f |
| 8 | 8 | ||
| 9 | #define PROTOCOL_VERSION 0x163 | 9 | #define PROTOCOL_VERSION 0x164 |
| 10 | #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00) | 10 | #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00) |
| 11 | #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff) | 11 | #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff) |
| 12 | 12 | ||
| @@ -44,7 +44,8 @@ typedef enum { | |||
| 44 | wopQueryValidDerivers = 33, | 44 | wopQueryValidDerivers = 33, |
| 45 | wopOptimiseStore = 34, | 45 | wopOptimiseStore = 34, |
| 46 | wopVerifyStore = 35, | 46 | wopVerifyStore = 35, |
| 47 | wopBuiltinBuilders = 80 | 47 | wopBuiltinBuilders = 80, |
| 48 | wopSubstituteURLs = 81 | ||
| 48 | } WorkerOp; | 49 | } WorkerOp; |
| 49 | 50 | ||
| 50 | 51 | ||
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index 497de11a048..4cb05c802e0 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, | |||
| 736 | break; | 736 | break; |
| 737 | } | 737 | } |
| 738 | 738 | ||
| 739 | case wopSubstituteURLs: { | ||
| 740 | startWork(); | ||
| 741 | Strings urls; | ||
| 742 | if (settings.get("build-use-substitutes", std::string("false")) == "true") { | ||
| 743 | /* First check the client-provided substitute URLs, then those | ||
| 744 | passed to the daemon. */ | ||
| 745 | auto str = settings.get("untrusted-substitute-urls", std::string("")); | ||
| 746 | if (str.empty()) { | ||
| 747 | str = settings.get("substitute-urls", std::string("")); | ||
| 748 | } | ||
| 749 | urls = tokenizeString<Strings>(str); | ||
| 750 | } | ||
| 751 | stopWork(); | ||
| 752 | writeStrings(urls, to); | ||
| 753 | break; | ||
| 754 | } | ||
| 755 | |||
| 739 | default: | 756 | default: |
| 740 | throw Error(format("invalid operation %1%") % op); | 757 | throw Error(format("invalid operation %1%") % op); |
| 741 | } | 758 | } |
