[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/04: daemon: Add 'built-in-builders' RPC.
From: |
Ludovic Courtès |
Subject: |
04/04: daemon: Add 'built-in-builders' RPC. |
Date: |
Sun, 13 Nov 2016 22:50:44 +0000 (UTC) |
civodul pushed a commit to branch wip-oob-download
in repository guix.
commit 2e094baf66c145d52ad3e22a91574547fc1ff91c
Author: Ludovic Courtès <address@hidden>
Date: Sun Nov 13 22:59:54 2016 +0100
daemon: Add 'built-in-builders' RPC.
* nix/libstore/builtins.cc (builtinBuilderNames): New function.
* nix/libstore/builtins.hh (builtinBuilderNames): New declaration.
* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x160.
(WorkerOp)[wopBuiltinBuilders]: New value.
* nix/nix-daemon/nix-daemon.cc (performOp): Handle it.
* guix/store.scm (operation-id)[built-in-builders]: New value.
* guix/store.scm (read-arg): Add 'string-list'.
(built-in-builders): New procedure.
* tests/derivations.scm ("built-in-builders"): New test.
---
guix/store.scm | 25 +++++++++++++++++++++++--
nix/libstore/builtins.cc | 10 ++++++++++
nix/libstore/builtins.hh | 3 +++
nix/libstore/worker-protocol.hh | 5 +++--
nix/nix-daemon/nix-daemon.cc | 9 +++++++++
tests/derivations.scm | 4 ++++
6 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/guix/store.scm b/guix/store.scm
index 43cfda9..3047dc3 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -95,6 +95,7 @@
path-info-registration-time
path-info-nar-size
+ built-in-builders
references
references/substitutes
requisites
@@ -187,7 +188,8 @@
(query-substitutable-paths 32)
(query-valid-derivers 33)
(optimize-store 34)
- (verify-store 35))
+ (verify-store 35)
+ (built-in-builders 80))
(define-enumerate-type hash-algo
;; hash.hh
@@ -283,7 +285,7 @@
(write-string (bytevector->base16-string arg) p))))
(define-syntax read-arg
- (syntax-rules (integer boolean string store-path store-path-list
+ (syntax-rules (integer boolean string store-path store-path-list string-list
substitutable-path-list path-info base16)
((_ integer p)
(read-int p))
@@ -295,6 +297,8 @@
(read-store-path p))
((_ store-path-list p)
(read-store-path-list p))
+ ((_ string-list p)
+ (read-string-list p))
((_ substitutable-path-list p)
(read-substitutable-path-list p))
((_ path-info p)
@@ -914,6 +918,23 @@ that there is no guarantee that the order of the resulting
list matches the
order of PATHS."
substitutable-path-list))
+(define built-in-builders
+ (let ((builders (operation (built-in-builders)
+ "Return the built-in builders."
+ string-list)))
+ (lambda (store)
+ "Return the names of the supported built-in derivation builders
+supported by STORE."
+ ;; Check whether STORE's version supports this RPC and built-in
+ ;; derivation builders in general, which appeared in Guix > 0.11.0.
+ ;; Return the empty list if it doesn't. Note that this RPC does not
+ ;; exist in 'nix-daemon'.
+ (if (or (> (nix-server-major-version store) #x100)
+ (and (= (nix-server-major-version store) #x100)
+ (>= (nix-server-minor-version store) #x60)))
+ (builders store)
+ '()))))
+
(define-operation (optimize-store)
"Optimize the store by hard-linking identical files (\"deduplication\".)
Return #t on success."
diff --git a/nix/libstore/builtins.cc b/nix/libstore/builtins.cc
index b6fd63d..24e20c8 100644
--- a/nix/libstore/builtins.cc
+++ b/nix/libstore/builtins.cc
@@ -87,4 +87,14 @@ derivationBuilder lookupBuiltinBuilder(const std::string &
name)
return NULL;
}
+std::list<std::string> builtinBuilderNames()
+{
+ std::list<std::string> result;
+ for(auto&& iter: builtins)
+ {
+ result.push_back(iter.first);
+ }
+ return result;
+}
+
}
diff --git a/nix/libstore/builtins.hh b/nix/libstore/builtins.hh
index 48391c9..bd133c1 100644
--- a/nix/libstore/builtins.hh
+++ b/nix/libstore/builtins.hh
@@ -36,4 +36,7 @@ namespace nix {
/* Return the built-in builder called BUILDER, or NULL if none was
found. */
derivationBuilder lookupBuiltinBuilder(const std::string &builder);
+
+ /* Return the list of supported built-in builder names. */
+ std::list<std::string> builtinBuilderNames();
}
diff --git a/nix/libstore/worker-protocol.hh b/nix/libstore/worker-protocol.hh
index 7b7be4a..bdeaca2 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 0x10f
+#define PROTOCOL_VERSION 0x160
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
@@ -43,7 +43,8 @@ typedef enum {
wopQuerySubstitutablePaths = 32,
wopQueryValidDerivers = 33,
wopOptimiseStore = 34,
- wopVerifyStore = 35
+ wopVerifyStore = 35,
+ wopBuiltinBuilders = 80
} WorkerOp;
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index 35c284f..9b29b3e 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -6,6 +6,7 @@
#include "archive.hh"
#include "affinity.hh"
#include "globals.hh"
+#include "builtins.hh"
#include <algorithm>
@@ -671,6 +672,14 @@ static void performOp(bool trusted, unsigned int
clientVersion,
break;
}
+ case wopBuiltinBuilders: {
+ startWork();
+ auto names = builtinBuilderNames();
+ stopWork();
+ writeStrings(names, to);
+ break;
+ }
+
default:
throw Error(format("invalid operation %1%") % op);
}
diff --git a/tests/derivations.scm b/tests/derivations.scm
index d13014f..efffb25 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -205,6 +205,10 @@
(= (stat:ino (lstat file1))
(stat:ino (lstat file2))))))))
+(test-equal "built-in-builders"
+ '("download")
+ (built-in-builders %store))
+
(test-assert "unknown built-in builder"
(let ((drv (derivation %store "ohoh" "builtin:does-not-exist" '())))
(guard (c ((nix-protocol-error? c)