daemon: Add 'buildMode' parameter to 'buildPaths' RPC.
* 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.
This commit is contained in:
parent
e134baae77
commit
708d907000
|
@ -462,11 +462,18 @@ Paths RemoteStore::importPaths(bool requireSignature, Source & source)
|
||||||
|
|
||||||
void RemoteStore::buildPaths(const PathSet & drvPaths, BuildMode buildMode)
|
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();
|
openConnection();
|
||||||
writeInt(wopBuildPaths, to);
|
writeInt(wopBuildPaths, to);
|
||||||
if (GET_PROTOCOL_MINOR(daemonVersion) >= 13)
|
if (GET_PROTOCOL_MINOR(daemonVersion) >= 13) {
|
||||||
writeStrings(drvPaths, to);
|
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 {
|
else {
|
||||||
/* For backwards compatibility with old daemons, strip output
|
/* For backwards compatibility with old daemons, strip output
|
||||||
identifiers. */
|
identifiers. */
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace nix {
|
||||||
#define WORKER_MAGIC_1 0x6e697863
|
#define WORKER_MAGIC_1 0x6e697863
|
||||||
#define WORKER_MAGIC_2 0x6478696f
|
#define WORKER_MAGIC_2 0x6478696f
|
||||||
|
|
||||||
#define PROTOCOL_VERSION 0x10e
|
#define PROTOCOL_VERSION 0x10f
|
||||||
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
||||||
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
||||||
|
|
||||||
|
|
|
@ -451,8 +451,17 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
||||||
|
|
||||||
case wopBuildPaths: {
|
case wopBuildPaths: {
|
||||||
PathSet drvs = readStorePaths<PathSet>(from);
|
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();
|
startWork();
|
||||||
store->buildPaths(drvs);
|
store->buildPaths(drvs, mode);
|
||||||
stopWork();
|
stopWork();
|
||||||
writeInt(1, to);
|
writeInt(1, to);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue