about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-12-02T17·13+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-12-02T17·14+0100
commitd1e3bf01bce7d8502610532077f6f55c3df4de2c (patch)
treebe09364c3f1ec59db565c5eabe13b62661c6d3e0 /src
parent8063fc497ab78fa72962b93874fe25dcca2b55ed (diff)
daemon: Add 'buildMode' parameter to 'buildPaths' RPC
Diffstat (limited to 'src')
-rw-r--r--src/libstore/remote-store.cc12
-rw-r--r--src/libstore/worker-protocol.hh2
-rw-r--r--src/nix-daemon/nix-daemon.cc11
3 files changed, 20 insertions, 5 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index ed9895ac81..262e4650bf 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -438,12 +438,18 @@ Paths RemoteStore::importPaths(bool requireSignature, Source & source)
 
 void RemoteStore::buildPaths(const PathSet & drvPaths, BuildMode buildMode)
 {
-    if (buildMode != bmNormal) throw Error("repairing or checking is not supported when building through the Nix daemon");
     openConnection();
     to << wopBuildPaths;
-    if (GET_PROTOCOL_MINOR(daemonVersion) >= 13)
+    if (GET_PROTOCOL_MINOR(daemonVersion) >= 13) {
         to << drvPaths;
-    else {
+        if (GET_PROTOCOL_MINOR(daemonVersion) >= 15)
+            to << buildMode;
+        else
+            /* Old daemons did not take a 'buildMode' parameter, so we
+               need to validate it here on the client side.  */
+            if (buildMode != bmNormal)
+                throw Error("repairing or checking is not supported when building through the Nix daemon");
+    } else {
         /* For backwards compatibility with old daemons, strip output
            identifiers. */
         PathSet drvPaths2;
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index 5a0ef5117a..7d9bcb58a2 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -6,7 +6,7 @@ namespace nix {
 #define WORKER_MAGIC_1 0x6e697863
 #define WORKER_MAGIC_2 0x6478696f
 
-#define PROTOCOL_VERSION 0x10e
+#define PROTOCOL_VERSION 0x10f
 #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
 #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
 
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index e97d1dab17..c5e11afa15 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -319,8 +319,17 @@ static void performOp(bool trusted, unsigned int clientVersion,
 
     case wopBuildPaths: {
         PathSet drvs = readStorePaths<PathSet>(from);
+        BuildMode mode = bmNormal;
+        if (GET_PROTOCOL_MINOR(clientVersion) >= 15) {
+            mode = (BuildMode)readInt(from);
+
+	    /* Repairing is not atomic, so disallowed for "untrusted"
+	       clients.  */
+            if (mode == bmRepair && !trusted)
+                throw Error("repairing is not supported when building through the Nix daemon");
+        }
         startWork();
-        store->buildPaths(drvs);
+        store->buildPaths(drvs, mode);
         stopWork();
         to << 1;
         break;