Skip to content

Commit be64fbb

Browse files
committed
RemoteStore / nix-daemon: Drop support for Nix < 1.0
1 parent 6601e46 commit be64fbb

File tree

2 files changed

+33
-44
lines changed

2 files changed

+33
-44
lines changed

src/libstore/remote-store.cc

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ ref<RemoteStore::Connection> RemoteStore::openConnection()
9494
conn->daemonVersion = readInt(conn->from);
9595
if (GET_PROTOCOL_MAJOR(conn->daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION))
9696
throw Error("Nix daemon protocol version not supported");
97+
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 10)
98+
throw Error("the Nix daemon version is too old");
9799
conn->to << PROTOCOL_VERSION;
98100

99101
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 14) {
@@ -127,17 +129,13 @@ void RemoteStore::setOptions(ref<Connection> conn)
127129
<< settings.tryFallback
128130
<< verbosity
129131
<< settings.maxBuildJobs
130-
<< settings.maxSilentTime;
131-
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 2)
132-
conn->to << settings.useBuildHook;
133-
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 4)
134-
conn->to << (settings.verboseBuild ? lvlError : lvlVomit)
135-
<< 0 // obsolete log type
136-
<< 0 /* obsolete print build trace */;
137-
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 6)
138-
conn->to << settings.buildCores;
139-
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 10)
140-
conn->to << settings.useSubstitutes;
132+
<< settings.maxSilentTime
133+
<< settings.useBuildHook
134+
<< (settings.verboseBuild ? lvlError : lvlVomit)
135+
<< 0 // obsolete log type
136+
<< 0 /* obsolete print build trace */
137+
<< settings.buildCores
138+
<< settings.useSubstitutes;
141139

142140
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 12) {
143141
Settings::SettingsMap overrides = settings.getOverrides();
@@ -213,8 +211,6 @@ void RemoteStore::querySubstitutablePathInfos(const PathSet & paths,
213211

214212
auto conn(connections->get());
215213

216-
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 3) return;
217-
218214
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 12) {
219215

220216
for (auto & i : paths) {
@@ -227,7 +223,7 @@ void RemoteStore::querySubstitutablePathInfos(const PathSet & paths,
227223
if (info.deriver != "") assertStorePath(info.deriver);
228224
info.references = readStorePaths<PathSet>(*this, conn->from);
229225
info.downloadSize = readLongLong(conn->from);
230-
info.narSize = GET_PROTOCOL_MINOR(conn->daemonVersion) >= 7 ? readLongLong(conn->from) : 0;
226+
info.narSize = readLongLong(conn->from);
231227
infos[i] = info;
232228
}
233229

@@ -481,11 +477,11 @@ void RemoteStore::collectGarbage(const GCOptions & options, GCResults & results)
481477
{
482478
auto conn(connections->get());
483479

484-
conn->to << wopCollectGarbage << options.action << options.pathsToDelete << options.ignoreLiveness
485-
<< options.maxFreed << 0;
486-
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 5)
480+
conn->to
481+
<< wopCollectGarbage << options.action << options.pathsToDelete << options.ignoreLiveness
482+
<< options.maxFreed
487483
/* removed options */
488-
conn->to << 0 << 0;
484+
<< 0 << 0 << 0;
489485

490486
conn->processStderr();
491487

@@ -562,7 +558,7 @@ void RemoteStore::Connection::processStderr(Sink * sink, Source * source)
562558
}
563559
if (msg == STDERR_ERROR) {
564560
string error = readString(from);
565-
unsigned int status = GET_PROTOCOL_MINOR(daemonVersion) >= 8 ? readInt(from) : 1;
561+
unsigned int status = readInt(from);
566562
throw Error(format("%1%") % error, status);
567563
}
568564
else if (msg != STDERR_LAST)

src/nix-daemon/nix-daemon.cc

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,10 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
413413
options.pathsToDelete = readStorePaths<PathSet>(*store, from);
414414
options.ignoreLiveness = readInt(from);
415415
options.maxFreed = readLongLong(from);
416-
readInt(from); // obsolete field
417-
if (GET_PROTOCOL_MINOR(clientVersion) >= 5) {
418-
/* removed options */
419-
readInt(from);
420-
readInt(from);
421-
}
416+
// obsolete fields
417+
readInt(from);
418+
readInt(from);
419+
readInt(from);
422420

423421
GCResults results;
424422

@@ -440,17 +438,12 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
440438
verbosity = (Verbosity) readInt(from);
441439
settings.set("build-max-jobs", std::to_string(readInt(from)));
442440
settings.set("build-max-silent-time", std::to_string(readInt(from)));
443-
if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
444-
settings.useBuildHook = readInt(from) != 0;
445-
if (GET_PROTOCOL_MINOR(clientVersion) >= 4) {
446-
settings.verboseBuild = lvlError == (Verbosity) readInt(from);
447-
readInt(from); // obsolete logType
448-
readInt(from); // obsolete printBuildTrace
449-
}
450-
if (GET_PROTOCOL_MINOR(clientVersion) >= 6)
451-
settings.set("build-cores", std::to_string(readInt(from)));
452-
if (GET_PROTOCOL_MINOR(clientVersion) >= 10)
453-
settings.set("build-use-substitutes", readInt(from) ? "true" : "false");
441+
settings.useBuildHook = readInt(from) != 0;
442+
settings.verboseBuild = lvlError == (Verbosity) readInt(from);
443+
readInt(from); // obsolete logType
444+
readInt(from); // obsolete printBuildTrace
445+
settings.set("build-cores", std::to_string(readInt(from)));
446+
settings.set("build-use-substitutes", readInt(from) ? "true" : "false");
454447
if (GET_PROTOCOL_MINOR(clientVersion) >= 12) {
455448
unsigned int n = readInt(from);
456449
for (unsigned int i = 0; i < n; i++) {
@@ -478,9 +471,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
478471
if (i == infos.end())
479472
to << 0;
480473
else {
481-
to << 1 << i->second.deriver << i->second.references << i->second.downloadSize;
482-
if (GET_PROTOCOL_MINOR(clientVersion) >= 7)
483-
to << i->second.narSize;
474+
to << 1 << i->second.deriver << i->second.references << i->second.downloadSize << i->second.narSize;
484475
}
485476
break;
486477
}
@@ -585,11 +576,13 @@ static void processConnection(bool trusted)
585576
to.flush();
586577
unsigned int clientVersion = readInt(from);
587578

579+
if (clientVersion < 0x10a)
580+
throw Error("the Nix client version is too old");
581+
588582
if (GET_PROTOCOL_MINOR(clientVersion) >= 14 && readInt(from))
589583
setAffinityTo(readInt(from));
590584

591-
if (GET_PROTOCOL_MINOR(clientVersion) >= 11)
592-
readInt(from); // obsolete reserveSpace
585+
readInt(from); // obsolete reserveSpace
593586

594587
/* Send startup error messages to the client. */
595588
startWork();
@@ -636,10 +629,10 @@ static void processConnection(bool trusted)
636629
during addTextToStore() / importPath(). If that
637630
happens, just send the error message and exit. */
638631
bool errorAllowed = canSendStderr;
639-
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? e.status : 0);
632+
stopWork(false, e.msg(), e.status);
640633
if (!errorAllowed) throw;
641634
} catch (std::bad_alloc & e) {
642-
stopWork(false, "Nix daemon out of memory", GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0);
635+
stopWork(false, "Nix daemon out of memory", 1);
643636
throw;
644637
}
645638

@@ -653,7 +646,7 @@ static void processConnection(bool trusted)
653646
printMsg(lvlDebug, format("%1% operations") % opCount);
654647

655648
} catch (Error & e) {
656-
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0);
649+
stopWork(false, e.msg(), 1);
657650
to.flush();
658651
return;
659652
}

0 commit comments

Comments
 (0)