@@ -73,6 +73,8 @@ void RemoteStore::initConnection(Connection & conn)
73
73
try {
74
74
auto [protoVersion, features] =
75
75
WorkerProto::BasicClientConnection::handshake (conn.to , tee, PROTOCOL_VERSION, WorkerProto::allFeatures);
76
+ if (protoVersion < 256 + 18 )
77
+ throw Error (" the Nix daemon version is too old" );
76
78
conn.protoVersion = protoVersion;
77
79
conn.features = features;
78
80
} catch (SerialisationError & e) {
@@ -109,24 +111,22 @@ void RemoteStore::setOptions(Connection & conn)
109
111
<< 0 /* obsolete print build trace */
110
112
<< settings.buildCores << settings.useSubstitutes ;
111
113
112
- if (GET_PROTOCOL_MINOR (conn.protoVersion ) >= 12 ) {
113
- std::map<std::string, nix::Config::SettingInfo> overrides;
114
- settings.getSettings (overrides, true ); // libstore settings
115
- fileTransferSettings.getSettings (overrides, true );
116
- overrides.erase (settings.keepFailed .name );
117
- overrides.erase (settings.keepGoing .name );
118
- overrides.erase (settings.tryFallback .name );
119
- overrides.erase (settings.maxBuildJobs .name );
120
- overrides.erase (settings.maxSilentTime .name );
121
- overrides.erase (settings.buildCores .name );
122
- overrides.erase (settings.useSubstitutes .name );
123
- overrides.erase (loggerSettings.showTrace .name );
124
- overrides.erase (experimentalFeatureSettings.experimentalFeatures .name );
125
- overrides.erase (" plugin-files" );
126
- conn.to << overrides.size ();
127
- for (auto & i : overrides)
128
- conn.to << i.first << i.second .value ;
129
- }
114
+ std::map<std::string, nix::Config::SettingInfo> overrides;
115
+ settings.getSettings (overrides, true ); // libstore settings
116
+ fileTransferSettings.getSettings (overrides, true );
117
+ overrides.erase (settings.keepFailed .name );
118
+ overrides.erase (settings.keepGoing .name );
119
+ overrides.erase (settings.tryFallback .name );
120
+ overrides.erase (settings.maxBuildJobs .name );
121
+ overrides.erase (settings.maxSilentTime .name );
122
+ overrides.erase (settings.buildCores .name );
123
+ overrides.erase (settings.useSubstitutes .name );
124
+ overrides.erase (loggerSettings.showTrace .name );
125
+ overrides.erase (experimentalFeatureSettings.experimentalFeatures .name );
126
+ overrides.erase (" plugin-files" );
127
+ conn.to << overrides.size ();
128
+ for (auto & i : overrides)
129
+ conn.to << i.first << i.second .value ;
130
130
131
131
auto ex = conn.processStderrReturn ();
132
132
if (ex)
@@ -167,15 +167,7 @@ bool RemoteStore::isValidPathUncached(const StorePath & path)
167
167
StorePathSet RemoteStore::queryValidPaths (const StorePathSet & paths, SubstituteFlag maybeSubstitute)
168
168
{
169
169
auto conn (getConnection ());
170
- if (GET_PROTOCOL_MINOR (conn->protoVersion ) < 12 ) {
171
- StorePathSet res;
172
- for (auto & i : paths)
173
- if (isValidPath (i))
174
- res.insert (i);
175
- return res;
176
- } else {
177
- return conn->queryValidPaths (*this , &conn.daemonException , paths, maybeSubstitute);
178
- }
170
+ return conn->queryValidPaths (*this , &conn.daemonException , paths, maybeSubstitute);
179
171
}
180
172
181
173
StorePathSet RemoteStore::queryAllValidPaths ()
@@ -189,21 +181,10 @@ StorePathSet RemoteStore::queryAllValidPaths()
189
181
StorePathSet RemoteStore::querySubstitutablePaths (const StorePathSet & paths)
190
182
{
191
183
auto conn (getConnection ());
192
- if (GET_PROTOCOL_MINOR (conn->protoVersion ) < 12 ) {
193
- StorePathSet res;
194
- for (auto & i : paths) {
195
- conn->to << WorkerProto::Op::HasSubstitutes << printStorePath (i);
196
- conn.processStderr ();
197
- if (readInt (conn->from ))
198
- res.insert (i);
199
- }
200
- return res;
201
- } else {
202
- conn->to << WorkerProto::Op::QuerySubstitutablePaths;
203
- WorkerProto::write (*this , *conn, paths);
204
- conn.processStderr ();
205
- return WorkerProto::Serialise<StorePathSet>::read (*this , *conn);
206
- }
184
+ conn->to << WorkerProto::Op::QuerySubstitutablePaths;
185
+ WorkerProto::write (*this , *conn, paths);
186
+ conn.processStderr ();
187
+ return WorkerProto::Serialise<StorePathSet>::read (*this , *conn);
207
188
}
208
189
209
190
void RemoteStore::querySubstitutablePathInfos (const StorePathCAMap & pathsMap, SubstitutablePathInfos & infos)
@@ -213,45 +194,24 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
213
194
214
195
auto conn (getConnection ());
215
196
216
- if (GET_PROTOCOL_MINOR (conn->protoVersion ) < 12 ) {
217
-
218
- for (auto & i : pathsMap) {
219
- SubstitutablePathInfo info;
220
- conn->to << WorkerProto::Op::QuerySubstitutablePathInfo << printStorePath (i.first );
221
- conn.processStderr ();
222
- unsigned int reply = readInt (conn->from );
223
- if (reply == 0 )
224
- continue ;
225
- auto deriver = readString (conn->from );
226
- if (deriver != " " )
227
- info.deriver = parseStorePath (deriver);
228
- info.references = WorkerProto::Serialise<StorePathSet>::read (*this , *conn);
229
- info.downloadSize = readLongLong (conn->from );
230
- info.narSize = readLongLong (conn->from );
231
- infos.insert_or_assign (i.first , std::move (info));
232
- }
233
-
234
- } else {
235
-
236
- conn->to << WorkerProto::Op::QuerySubstitutablePathInfos;
237
- if (GET_PROTOCOL_MINOR (conn->protoVersion ) < 22 ) {
238
- StorePathSet paths;
239
- for (auto & path : pathsMap)
240
- paths.insert (path.first );
241
- WorkerProto::write (*this , *conn, paths);
242
- } else
243
- WorkerProto::write (*this , *conn, pathsMap);
244
- conn.processStderr ();
245
- size_t count = readNum<size_t >(conn->from );
246
- for (size_t n = 0 ; n < count; n++) {
247
- SubstitutablePathInfo & info (infos[parseStorePath (readString (conn->from ))]);
248
- auto deriver = readString (conn->from );
249
- if (deriver != " " )
250
- info.deriver = parseStorePath (deriver);
251
- info.references = WorkerProto::Serialise<StorePathSet>::read (*this , *conn);
252
- info.downloadSize = readLongLong (conn->from );
253
- info.narSize = readLongLong (conn->from );
254
- }
197
+ conn->to << WorkerProto::Op::QuerySubstitutablePathInfos;
198
+ if (GET_PROTOCOL_MINOR (conn->protoVersion ) < 22 ) {
199
+ StorePathSet paths;
200
+ for (auto & path : pathsMap)
201
+ paths.insert (path.first );
202
+ WorkerProto::write (*this , *conn, paths);
203
+ } else
204
+ WorkerProto::write (*this , *conn, pathsMap);
205
+ conn.processStderr ();
206
+ size_t count = readNum<size_t >(conn->from );
207
+ for (size_t n = 0 ; n < count; n++) {
208
+ SubstitutablePathInfo & info (infos[parseStorePath (readString (conn->from ))]);
209
+ auto deriver = readString (conn->from );
210
+ if (deriver != " " )
211
+ info.deriver = parseStorePath (deriver);
212
+ info.references = WorkerProto::Serialise<StorePathSet>::read (*this , *conn);
213
+ info.downloadSize = readLongLong (conn->from );
214
+ info.narSize = readLongLong (conn->from );
255
215
}
256
216
}
257
217
@@ -466,36 +426,20 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source, Repair
466
426
{
467
427
auto conn (getConnection ());
468
428
469
- if (GET_PROTOCOL_MINOR (conn->protoVersion ) < 18 ) {
470
- auto source2 = sinkToSource ([&](Sink & sink) {
471
- sink << 1 // == path follows
472
- ;
473
- copyNAR (source, sink);
474
- sink << exportMagic << printStorePath (info.path );
475
- WorkerProto::write (*this , *conn, info.references );
476
- sink << (info.deriver ? printStorePath (*info.deriver ) : " " ) << 0 // == no legacy signature
477
- << 0 // == no path follows
478
- ;
479
- });
480
- conn->importPaths (*this , &conn.daemonException , *source2);
481
- }
482
-
483
- else {
484
- conn->to << WorkerProto::Op::AddToStoreNar << printStorePath (info.path )
485
- << (info.deriver ? printStorePath (*info.deriver ) : " " )
486
- << info.narHash .to_string (HashFormat::Base16, false );
487
- WorkerProto::write (*this , *conn, info.references );
488
- conn->to << info.registrationTime << info.narSize << info.ultimate << info.sigs << renderContentAddress (info.ca )
489
- << repair << !checkSigs;
490
-
491
- if (GET_PROTOCOL_MINOR (conn->protoVersion ) >= 23 ) {
492
- conn.withFramedSink ([&](Sink & sink) { copyNAR (source, sink); });
493
- } else if (GET_PROTOCOL_MINOR (conn->protoVersion ) >= 21 ) {
494
- conn.processStderr (0 , &source);
495
- } else {
496
- copyNAR (source, conn->to );
497
- conn.processStderr (0 , nullptr );
498
- }
429
+ conn->to << WorkerProto::Op::AddToStoreNar << printStorePath (info.path )
430
+ << (info.deriver ? printStorePath (*info.deriver ) : " " )
431
+ << info.narHash .to_string (HashFormat::Base16, false );
432
+ WorkerProto::write (*this , *conn, info.references );
433
+ conn->to << info.registrationTime << info.narSize << info.ultimate << info.sigs << renderContentAddress (info.ca )
434
+ << repair << !checkSigs;
435
+
436
+ if (GET_PROTOCOL_MINOR (conn->protoVersion ) >= 23 ) {
437
+ conn.withFramedSink ([&](Sink & sink) { copyNAR (source, sink); });
438
+ } else if (GET_PROTOCOL_MINOR (conn->protoVersion ) >= 21 ) {
439
+ conn.processStderr (0 , &source);
440
+ } else {
441
+ copyNAR (source, conn->to );
442
+ conn.processStderr (0 , nullptr );
499
443
}
500
444
}
501
445
@@ -618,15 +562,8 @@ void RemoteStore::buildPaths(
618
562
619
563
auto conn (getConnection ());
620
564
conn->to << WorkerProto::Op::BuildPaths;
621
- assert (GET_PROTOCOL_MINOR (conn->protoVersion ) >= 13 );
622
565
WorkerProto::write (*this , *conn, drvPaths);
623
- if (GET_PROTOCOL_MINOR (conn->protoVersion ) >= 15 )
624
- conn->to << buildMode;
625
- else
626
- /* Old daemons did not take a 'buildMode' parameter, so we
627
- need to validate it here on the client side. */
628
- if (buildMode != bmNormal)
629
- throw Error (" repairing or checking is not supported when building through the Nix daemon" );
566
+ conn->to << buildMode;
630
567
conn.processStderr ();
631
568
readInt (conn->from );
632
569
}
0 commit comments