unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] daemon: Add 'buildMode' parameter to 'buildPaths' RPC.
@ 2015-12-02 17:03 Ludovic Courtès
  2015-12-02 17:48 ` Shea Levy
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2015-12-02 17:03 UTC (permalink / raw)
  To: eelco.dolstra; +Cc: guix-devel, Ludovic Courtès, nix-dev

[-- Attachment #1: Type: text/plain, Size: 548 bytes --]


* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x10f.
* nix/libstore/remote-store.cc (RemoteStore::buildPaths): Send the
BUILDMODE when the daemon supports it.  Reject invalid values of
BUILDMODE for old daemons.
* nix/nix-daemon/nix-daemon.cc (performOp) <wopBuildPaths>: Read the
build mode when the client supports it.
---
 nix/libstore/remote-store.cc    | 11 +++++++++--
 nix/libstore/worker-protocol.hh |  2 +-
 nix/nix-daemon/nix-daemon.cc    | 11 ++++++++++-
 3 files changed, 20 insertions(+), 4 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-daemon-Add-buildMode-parameter-to-buildPaths-RPC.patch --]
[-- Type: text/x-patch; name="0001-daemon-Add-buildMode-parameter-to-buildPaths-RPC.patch", Size: 2546 bytes --]

diff --git a/nix/libstore/remote-store.cc b/nix/libstore/remote-store.cc
index 0539bbe..324ef5e 100644
--- a/nix/libstore/remote-store.cc
+++ b/nix/libstore/remote-store.cc
@@ -462,11 +462,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();
     writeInt(wopBuildPaths, to);
-    if (GET_PROTOCOL_MINOR(daemonVersion) >= 13)
+    if (GET_PROTOCOL_MINOR(daemonVersion) >= 13) {
         writeStrings(drvPaths, to);
+        if (GET_PROTOCOL_MINOR(daemonVersion) >= 15) {
+            writeInt(buildMode, to);
+        }
+        /* Old daemons did not take a 'buildMode' parameter, so we need to
+           validate it here on the client side.  */
+        else 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. */
diff --git a/nix/libstore/worker-protocol.hh b/nix/libstore/worker-protocol.hh
index d037d74..7b7be4a 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 0x10e
+#define PROTOCOL_VERSION 0x10f
 #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
 #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
 
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index bd9eebe..c1e697b 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -451,8 +451,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();
         writeInt(1, to);
         break;

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] daemon: Add 'buildMode' parameter to 'buildPaths' RPC.
  2015-12-02 17:03 [PATCH] daemon: Add 'buildMode' parameter to 'buildPaths' RPC Ludovic Courtès
@ 2015-12-02 17:48 ` Shea Levy
  2015-12-03 10:48   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Shea Levy @ 2015-12-02 17:48 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel, eelco.dolstra, nix-dev

Can you resend with paths appropriate to the nix repo? There is no nix/ 
directory there.

~Shea

On 2015-12-02 12:03, Ludovic Courtès wrote:
> * nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x10f.
> * nix/libstore/remote-store.cc (RemoteStore::buildPaths): Send the
> BUILDMODE when the daemon supports it.  Reject invalid values of
> BUILDMODE for old daemons.
> * nix/nix-daemon/nix-daemon.cc (performOp) <wopBuildPaths>: Read the
> build mode when the client supports it.
> ---
>  nix/libstore/remote-store.cc    | 11 +++++++++--
>  nix/libstore/worker-protocol.hh |  2 +-
>  nix/nix-daemon/nix-daemon.cc    | 11 ++++++++++-
>  3 files changed, 20 insertions(+), 4 deletions(-)
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev

_______________________________________________
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] daemon: Add 'buildMode' parameter to 'buildPaths' RPC.
  2015-12-02 17:48 ` Shea Levy
@ 2015-12-03 10:48   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2015-12-03 10:48 UTC (permalink / raw)
  To: Shea Levy; +Cc: guix-devel, eelco.dolstra, nix-dev

Shea Levy <shea@shealevy.com> skribis:

> Can you resend with paths appropriate to the nix repo? There is no
> nix/ directory there.

Oops, my bad.  I think Eelco solved that already.

Sorry about that!

Ludo’.
_______________________________________________
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-03 10:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-02 17:03 [PATCH] daemon: Add 'buildMode' parameter to 'buildPaths' RPC Ludovic Courtès
2015-12-02 17:48 ` Shea Levy
2015-12-03 10:48   ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).