* Flag `--no-build-hook' to disable distributed builds.
* queryDeriver in daemon mode: don't barf if the other side returns an empty string (which means there is no deriver).
This commit is contained in:
		
							parent
							
								
									c05783ad67
								
							
						
					
					
						commit
						c370755583
					
				
					 9 changed files with 23 additions and 6 deletions
				
			
		| 
						 | 
					@ -146,7 +146,7 @@ while (scalar @tmp > 0) {
 | 
				
			||||||
    # probably wouldn't make that much sense; pumping lots of data
 | 
					    # probably wouldn't make that much sense; pumping lots of data
 | 
				
			||||||
    # around just to compress them won't gain that much.
 | 
					    # around just to compress them won't gain that much.
 | 
				
			||||||
    $ENV{"NIX_BUILD_HOOK"} = "";
 | 
					    $ENV{"NIX_BUILD_HOOK"} = "";
 | 
				
			||||||
    my $pid = open(READ, "$binDir/nix-store --realise @tmp2|")
 | 
					    my $pid = open(READ, "$binDir/nix-store --no-build-hook --realise @tmp2|")
 | 
				
			||||||
        or die "cannot run nix-store";
 | 
					        or die "cannot run nix-store";
 | 
				
			||||||
    while (<READ>) {
 | 
					    while (<READ>) {
 | 
				
			||||||
        chomp;
 | 
					        chomp;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -212,6 +212,8 @@ static void initAndRun(int argc, char * * argv)
 | 
				
			||||||
            readOnlyMode = true;
 | 
					            readOnlyMode = true;
 | 
				
			||||||
        else if (arg == "--max-silent-time")
 | 
					        else if (arg == "--max-silent-time")
 | 
				
			||||||
            maxSilentTime = getIntArg(arg, i, args.end());
 | 
					            maxSilentTime = getIntArg(arg, i, args.end());
 | 
				
			||||||
 | 
					        else if (arg == "--no-build-hook")
 | 
				
			||||||
 | 
					            useBuildHook = false;
 | 
				
			||||||
        else remaining.push_back(arg);
 | 
					        else remaining.push_back(arg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1247,6 +1247,7 @@ static string makeValidityRegistration(const PathSet & paths,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DerivationGoal::HookReply DerivationGoal::tryBuildHook()
 | 
					DerivationGoal::HookReply DerivationGoal::tryBuildHook()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    if (!useBuildHook) return rpDecline;
 | 
				
			||||||
    Path buildHook = getEnv("NIX_BUILD_HOOK");
 | 
					    Path buildHook = getEnv("NIX_BUILD_HOOK");
 | 
				
			||||||
    if (buildHook == "") return rpDecline;
 | 
					    if (buildHook == "") return rpDecline;
 | 
				
			||||||
    buildHook = absPath(buildHook);
 | 
					    buildHook = absPath(buildHook);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,6 +26,7 @@ bool readOnlyMode = false;
 | 
				
			||||||
string thisSystem = "unset";
 | 
					string thisSystem = "unset";
 | 
				
			||||||
unsigned int maxSilentTime = 0;
 | 
					unsigned int maxSilentTime = 0;
 | 
				
			||||||
Paths substituters;
 | 
					Paths substituters;
 | 
				
			||||||
 | 
					bool useBuildHook = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool settingsRead = false;
 | 
					static bool settingsRead = false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,10 @@ extern unsigned int maxSilentTime;
 | 
				
			||||||
   from a CD. */
 | 
					   from a CD. */
 | 
				
			||||||
extern Paths substituters;
 | 
					extern Paths substituters;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Whether to use build hooks (for distributed builds).  Sometimes
 | 
				
			||||||
 | 
					   users want to disable this from the command-line. */
 | 
				
			||||||
 | 
					extern bool useBuildHook;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Strings querySetting(const string & name, const Strings & def);
 | 
					Strings querySetting(const string & name, const Strings & def);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,7 +59,7 @@ RemoteStore::RemoteStore()
 | 
				
			||||||
        unsigned int magic = readInt(from);
 | 
					        unsigned int magic = readInt(from);
 | 
				
			||||||
        if (magic != WORKER_MAGIC_2) throw Error("protocol mismatch");
 | 
					        if (magic != WORKER_MAGIC_2) throw Error("protocol mismatch");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        unsigned int daemonVersion = readInt(from);
 | 
					        daemonVersion = readInt(from);
 | 
				
			||||||
        if (GET_PROTOCOL_MAJOR(daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION))
 | 
					        if (GET_PROTOCOL_MAJOR(daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION))
 | 
				
			||||||
            throw Error("Nix daemon protocol version not supported");
 | 
					            throw Error("Nix daemon protocol version not supported");
 | 
				
			||||||
        writeInt(PROTOCOL_VERSION, to);
 | 
					        writeInt(PROTOCOL_VERSION, to);
 | 
				
			||||||
| 
						 | 
					@ -169,6 +169,8 @@ void RemoteStore::setOptions()
 | 
				
			||||||
    writeInt(verbosity, to);
 | 
					    writeInt(verbosity, to);
 | 
				
			||||||
    writeInt(maxBuildJobs, to);
 | 
					    writeInt(maxBuildJobs, to);
 | 
				
			||||||
    writeInt(maxSilentTime, to);
 | 
					    writeInt(maxSilentTime, to);
 | 
				
			||||||
 | 
					    if (GET_PROTOCOL_MINOR(daemonVersion) >= 2)
 | 
				
			||||||
 | 
					        writeInt(useBuildHook, to);
 | 
				
			||||||
    processStderr();
 | 
					    processStderr();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -230,7 +232,9 @@ Path RemoteStore::queryDeriver(const Path & path)
 | 
				
			||||||
    writeInt(wopQueryDeriver, to);
 | 
					    writeInt(wopQueryDeriver, to);
 | 
				
			||||||
    writeString(path, to);
 | 
					    writeString(path, to);
 | 
				
			||||||
    processStderr();
 | 
					    processStderr();
 | 
				
			||||||
    return readStorePath(from);
 | 
					    Path drvPath = readString(from);
 | 
				
			||||||
 | 
					    if (drvPath != "") assertStorePath(drvPath);
 | 
				
			||||||
 | 
					    return drvPath;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,6 +71,7 @@ private:
 | 
				
			||||||
    FdSink to;
 | 
					    FdSink to;
 | 
				
			||||||
    FdSource from;
 | 
					    FdSource from;
 | 
				
			||||||
    Pid child;
 | 
					    Pid child;
 | 
				
			||||||
 | 
					    unsigned int daemonVersion;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void processStderr(Sink * sink = 0, Source * source = 0);
 | 
					    void processStderr(Sink * sink = 0, Source * source = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,8 +8,9 @@ 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 0x101
 | 
					#define PROTOCOL_VERSION 0x102
 | 
				
			||||||
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
 | 
					#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
 | 
				
			||||||
 | 
					#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef enum {
 | 
					typedef enum {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -223,7 +223,8 @@ struct TunnelSource : Source
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void performOp(Source & from, Sink & to, unsigned int op)
 | 
					static void performOp(unsigned int clientVersion,
 | 
				
			||||||
 | 
					    Source & from, Sink & to, unsigned int op)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    switch (op) {
 | 
					    switch (op) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -422,6 +423,8 @@ static void performOp(Source & from, Sink & to, unsigned int op)
 | 
				
			||||||
        verbosity = (Verbosity) readInt(from);
 | 
					        verbosity = (Verbosity) readInt(from);
 | 
				
			||||||
        maxBuildJobs = readInt(from);
 | 
					        maxBuildJobs = readInt(from);
 | 
				
			||||||
        maxSilentTime = readInt(from);
 | 
					        maxSilentTime = readInt(from);
 | 
				
			||||||
 | 
					        if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
 | 
				
			||||||
 | 
					            useBuildHook = readInt(from) != 0;
 | 
				
			||||||
        startWork();
 | 
					        startWork();
 | 
				
			||||||
        stopWork();
 | 
					        stopWork();
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
| 
						 | 
					@ -492,7 +495,7 @@ static void processConnection()
 | 
				
			||||||
        opCount++;
 | 
					        opCount++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            performOp(from, to, op);
 | 
					            performOp(clientVersion, from, to, op);
 | 
				
			||||||
        } catch (Error & e) {
 | 
					        } catch (Error & e) {
 | 
				
			||||||
            stopWork(false, e.msg());
 | 
					            stopWork(false, e.msg());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue