Skip to content

Commit c370755

Browse files
committed
* 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).
1 parent c05783a commit c370755

File tree

9 files changed

+23
-6
lines changed

9 files changed

+23
-6
lines changed

scripts/nix-push.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ while (scalar @tmp > 0) {
146146
# probably wouldn't make that much sense; pumping lots of data
147147
# around just to compress them won't gain that much.
148148
$ENV{"NIX_BUILD_HOOK"} = "";
149-
my $pid = open(READ, "$binDir/nix-store --realise @tmp2|")
149+
my $pid = open(READ, "$binDir/nix-store --no-build-hook --realise @tmp2|")
150150
or die "cannot run nix-store";
151151
while (<READ>) {
152152
chomp;

src/libmain/shared.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ static void initAndRun(int argc, char * * argv)
212212
readOnlyMode = true;
213213
else if (arg == "--max-silent-time")
214214
maxSilentTime = getIntArg(arg, i, args.end());
215+
else if (arg == "--no-build-hook")
216+
useBuildHook = false;
215217
else remaining.push_back(arg);
216218
}
217219

src/libstore/build.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ static string makeValidityRegistration(const PathSet & paths,
12471247

12481248
DerivationGoal::HookReply DerivationGoal::tryBuildHook()
12491249
{
1250+
if (!useBuildHook) return rpDecline;
12501251
Path buildHook = getEnv("NIX_BUILD_HOOK");
12511252
if (buildHook == "") return rpDecline;
12521253
buildHook = absPath(buildHook);

src/libstore/globals.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ bool readOnlyMode = false;
2626
string thisSystem = "unset";
2727
unsigned int maxSilentTime = 0;
2828
Paths substituters;
29+
bool useBuildHook = true;
2930

3031

3132
static bool settingsRead = false;

src/libstore/globals.hh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ extern unsigned int maxSilentTime;
7272
from a CD. */
7373
extern Paths substituters;
7474

75+
/* Whether to use build hooks (for distributed builds). Sometimes
76+
users want to disable this from the command-line. */
77+
extern bool useBuildHook;
78+
7579

7680
Strings querySetting(const string & name, const Strings & def);
7781

src/libstore/remote-store.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ RemoteStore::RemoteStore()
5959
unsigned int magic = readInt(from);
6060
if (magic != WORKER_MAGIC_2) throw Error("protocol mismatch");
6161

62-
unsigned int daemonVersion = readInt(from);
62+
daemonVersion = readInt(from);
6363
if (GET_PROTOCOL_MAJOR(daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION))
6464
throw Error("Nix daemon protocol version not supported");
6565
writeInt(PROTOCOL_VERSION, to);
@@ -169,6 +169,8 @@ void RemoteStore::setOptions()
169169
writeInt(verbosity, to);
170170
writeInt(maxBuildJobs, to);
171171
writeInt(maxSilentTime, to);
172+
if (GET_PROTOCOL_MINOR(daemonVersion) >= 2)
173+
writeInt(useBuildHook, to);
172174
processStderr();
173175
}
174176

@@ -230,7 +232,9 @@ Path RemoteStore::queryDeriver(const Path & path)
230232
writeInt(wopQueryDeriver, to);
231233
writeString(path, to);
232234
processStderr();
233-
return readStorePath(from);
235+
Path drvPath = readString(from);
236+
if (drvPath != "") assertStorePath(drvPath);
237+
return drvPath;
234238
}
235239

236240

src/libstore/remote-store.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ private:
7171
FdSink to;
7272
FdSource from;
7373
Pid child;
74+
unsigned int daemonVersion;
7475

7576
void processStderr(Sink * sink = 0, Source * source = 0);
7677

src/libstore/worker-protocol.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ namespace nix {
88
#define WORKER_MAGIC_1 0x6e697863
99
#define WORKER_MAGIC_2 0x6478696f
1010

11-
#define PROTOCOL_VERSION 0x101
11+
#define PROTOCOL_VERSION 0x102
1212
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
13+
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
1314

1415

1516
typedef enum {

src/nix-worker/nix-worker.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ struct TunnelSource : Source
223223
};
224224

225225

226-
static void performOp(Source & from, Sink & to, unsigned int op)
226+
static void performOp(unsigned int clientVersion,
227+
Source & from, Sink & to, unsigned int op)
227228
{
228229
switch (op) {
229230

@@ -422,6 +423,8 @@ static void performOp(Source & from, Sink & to, unsigned int op)
422423
verbosity = (Verbosity) readInt(from);
423424
maxBuildJobs = readInt(from);
424425
maxSilentTime = readInt(from);
426+
if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
427+
useBuildHook = readInt(from) != 0;
425428
startWork();
426429
stopWork();
427430
break;
@@ -492,7 +495,7 @@ static void processConnection()
492495
opCount++;
493496

494497
try {
495-
performOp(from, to, op);
498+
performOp(clientVersion, from, to, op);
496499
} catch (Error & e) {
497500
stopWork(false, e.msg());
498501
}

0 commit comments

Comments
 (0)