mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Implement buildDerivation() via the daemon
This commit is contained in:
parent
6e06a18d1b
commit
71a5161365
5 changed files with 34 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "archive.hh"
|
||||
#include "affinity.hh"
|
||||
#include "globals.hh"
|
||||
#include "derivations.hh"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -458,7 +459,14 @@ void RemoteStore::buildPaths(const PathSet & drvPaths, BuildMode buildMode)
|
|||
BuildResult RemoteStore::buildDerivation(const Path & drvPath, const BasicDerivation & drv,
|
||||
BuildMode buildMode)
|
||||
{
|
||||
throw Error("not implemented");
|
||||
openConnection();
|
||||
to << wopBuildDerivation << drvPath << drv << buildMode;
|
||||
processStderr();
|
||||
BuildResult res;
|
||||
unsigned int status;
|
||||
from >> status >> res.errorMsg;
|
||||
res.status = (BuildResult::Status) status;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ typedef enum {
|
|||
wopQuerySubstitutablePaths = 32,
|
||||
wopQueryValidDerivers = 33,
|
||||
wopOptimiseStore = 34,
|
||||
wopVerifyStore = 35
|
||||
wopVerifyStore = 35,
|
||||
wopBuildDerivation = 36,
|
||||
} WorkerOp;
|
||||
|
||||
|
||||
|
|
|
@ -248,6 +248,13 @@ Source & operator >> (Source & in, string & s)
|
|||
}
|
||||
|
||||
|
||||
Source & operator >> (Source & in, unsigned int & n)
|
||||
{
|
||||
n = readInt(in);
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
template<class T> T readStrings(Source & source)
|
||||
{
|
||||
unsigned int count = readInt(source);
|
||||
|
|
|
@ -143,6 +143,7 @@ string readString(Source & source);
|
|||
template<class T> T readStrings(Source & source);
|
||||
|
||||
Source & operator >> (Source & in, string & s);
|
||||
Source & operator >> (Source & in, unsigned int & n);
|
||||
|
||||
|
||||
MakeError(SerialisationError, Error)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "affinity.hh"
|
||||
#include "globals.hh"
|
||||
#include "monitor-fd.hh"
|
||||
#include "derivations.hh"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -325,6 +326,20 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
|||
break;
|
||||
}
|
||||
|
||||
case wopBuildDerivation: {
|
||||
Path drvPath = readStorePath(from);
|
||||
BasicDerivation drv;
|
||||
from >> drv;
|
||||
BuildMode buildMode = (BuildMode) readInt(from);
|
||||
startWork();
|
||||
if (!trusted)
|
||||
throw Error("you are not privileged to build derivations");
|
||||
auto res = store->buildDerivation(drvPath, drv, buildMode);
|
||||
stopWork();
|
||||
to << res.status << res.errorMsg;
|
||||
break;
|
||||
}
|
||||
|
||||
case wopEnsurePath: {
|
||||
Path path = readStorePath(from);
|
||||
startWork();
|
||||
|
|
Loading…
Reference in a new issue