2424
2525namespace nix {
2626
27- BinaryCacheStore::BinaryCacheStore (const Params & params)
28- : BinaryCacheStoreConfig(params)
29- , Store(params)
27+ BinaryCacheStore::BinaryCacheStore (Config & config)
28+ : config{config}
3029{
31- if (secretKeyFile != " " )
30+ if (config. secretKeyFile != " " )
3231 signers.push_back (std::make_unique<LocalSigner>(
33- SecretKey { readFile (secretKeyFile) }));
32+ SecretKey { readFile (config. secretKeyFile ) }));
3433
35- if (secretKeyFiles != " " ) {
36- std::stringstream ss (secretKeyFiles);
34+ if (config. secretKeyFiles != " " ) {
35+ std::stringstream ss (config. secretKeyFiles );
3736 Path keyPath;
3837 while (std::getline (ss, keyPath, ' ,' )) {
3938 signers.push_back (std::make_unique<LocalSigner>(
@@ -62,9 +61,9 @@ void BinaryCacheStore::init()
6261 throw Error (" binary cache '%s' is for Nix stores with prefix '%s', not '%s'" ,
6362 getUri (), value, storeDir);
6463 } else if (name == " WantMassQuery" ) {
65- wantMassQuery.setDefault (value == " 1" );
64+ config. wantMassQuery .setDefault (value == " 1" );
6665 } else if (name == " Priority" ) {
67- priority.setDefault (std::stoi (value));
66+ config. priority .setDefault (std::stoi (value));
6867 }
6968 }
7069 }
@@ -156,7 +155,11 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
156155 {
157156 FdSink fileSink (fdTemp.get ());
158157 TeeSink teeSinkCompressed { fileSink, fileHashSink };
159- auto compressionSink = makeCompressionSink (compression, teeSinkCompressed, parallelCompression, compressionLevel);
158+ auto compressionSink = makeCompressionSink (
159+ config.compression ,
160+ teeSinkCompressed,
161+ config.parallelCompression ,
162+ config.compressionLevel );
160163 TeeSink teeSinkUncompressed { *compressionSink, narHashSink };
161164 TeeSource teeSource { narSource, teeSinkUncompressed };
162165 narAccessor = makeNarAccessor (teeSource);
@@ -168,17 +171,17 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
168171
169172 auto info = mkInfo (narHashSink.finish ());
170173 auto narInfo = make_ref<NarInfo>(info);
171- narInfo->compression = compression;
174+ narInfo->compression = config. compression ;
172175 auto [fileHash, fileSize] = fileHashSink.finish ();
173176 narInfo->fileHash = fileHash;
174177 narInfo->fileSize = fileSize;
175178 narInfo->url = " nar/" + narInfo->fileHash ->to_string (HashFormat::Nix32, false ) + " .nar"
176- + (compression == " xz" ? " .xz" :
177- compression == " bzip2" ? " .bz2" :
178- compression == " zstd" ? " .zst" :
179- compression == " lzip" ? " .lzip" :
180- compression == " lz4" ? " .lz4" :
181- compression == " br" ? " .br" :
179+ + (config. compression == " xz" ? " .xz" :
180+ config. compression == " bzip2" ? " .bz2" :
181+ config. compression == " zstd" ? " .zst" :
182+ config. compression == " lzip" ? " .lzip" :
183+ config. compression == " lz4" ? " .lz4" :
184+ config. compression == " br" ? " .br" :
182185 " " );
183186
184187 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count ();
@@ -200,7 +203,7 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
200203
201204 /* Optionally write a JSON file containing a listing of the
202205 contents of the NAR. */
203- if (writeNARListing) {
206+ if (config. writeNARListing ) {
204207 nlohmann::json j = {
205208 {" version" , 1 },
206209 {" root" , listNar (ref<SourceAccessor>(narAccessor), CanonPath::root, true )},
@@ -212,7 +215,7 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
212215 /* Optionally maintain an index of DWARF debug info files
213216 consisting of JSON files named 'debuginfo/<build-id>' that
214217 specify the NAR file and member containing the debug info. */
215- if (writeDebugInfo) {
218+ if (config. writeDebugInfo ) {
216219
217220 CanonPath buildIdDir (" lib/debug/.build-id" );
218221
@@ -524,7 +527,7 @@ void BinaryCacheStore::registerDrvOutput(const Realisation& info) {
524527
525528ref<SourceAccessor> BinaryCacheStore::getFSAccessor (bool requireValidPath)
526529{
527- return make_ref<RemoteFSAccessor>(ref<Store>(shared_from_this ()), requireValidPath, localNarCache);
530+ return make_ref<RemoteFSAccessor>(ref<Store>(shared_from_this ()), requireValidPath, config. localNarCache );
528531}
529532
530533void BinaryCacheStore::addSignatures (const StorePath & storePath, const StringSet & sigs)
0 commit comments