libstore: asyncify getDefaultSubstituters

Change-Id: I078c5575f4941ab0d06ef9bf1e549b789e695afc
This commit is contained in:
eldritch horrors
2025-02-08 12:45:15 +00:00
parent bf1c5cb27d
commit af507e587f
8 changed files with 13 additions and 11 deletions
+1 -1
View File
@@ -729,7 +729,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
Finally roModeReset([&]() {
settings.readOnlyMode = false;
});
auto subs = getDefaultSubstituters();
auto subs = state.aio.blockOn(getDefaultSubstituters());
subs.push_front(evaluator.store);
@@ -34,7 +34,7 @@ try {
co_return WorkResult{ecSuccess};
}
subs = settings.useSubstitutes ? getDefaultSubstituters() : std::list<ref<Store>>();
subs = settings.useSubstitutes ? TRY_AWAIT(getDefaultSubstituters()) : std::list<ref<Store>>();
co_return co_await tryNext();
} catch (...) {
co_return result::current_exception();
+1 -1
View File
@@ -62,7 +62,7 @@ try {
if (settings.readOnlyMode)
throw Error("cannot substitute path '%s' - no write access to the Nix store", worker.store.printStorePath(storePath));
subs = settings.useSubstitutes ? getDefaultSubstituters() : std::list<ref<Store>>();
subs = settings.useSubstitutes ? TRY_AWAIT(getDefaultSubstituters()) : std::list<ref<Store>>();
BOOST_OUTCOME_CO_TRY(auto result, co_await tryNext());
result.storePath = storePath;
+1 -1
View File
@@ -1072,7 +1072,7 @@ try {
StorePathSet res;
for (auto & sub : getDefaultSubstituters()) {
for (auto & sub : TRY_AWAIT(getDefaultSubstituters())) {
if (remaining.empty()) break;
if (sub->config().storeDir != config_.storeDir) continue;
if (!sub->config().wantMassQuery) continue;
+1 -1
View File
@@ -251,7 +251,7 @@ struct QueryMissingContext
continue;
bool found = false;
for (auto &sub : getDefaultSubstituters()) {
for (auto &sub : aio.blockOn(getDefaultSubstituters())) {
auto realisation = sub->queryRealisation({hash, outputName});
if (!realisation)
continue;
+6 -4
View File
@@ -607,7 +607,7 @@ StorePathSet Store::queryDerivationOutputs(const StorePath & path)
kj::Promise<Result<void>> Store::querySubstitutablePathInfos(const StorePathCAMap & paths, SubstitutablePathInfos & infos)
try {
if (!settings.useSubstitutes) co_return result::success();
for (auto & sub : getDefaultSubstituters()) {
for (auto & sub : TRY_AWAIT(getDefaultSubstituters())) {
for (auto & path : paths) {
if (infos.count(path.first))
// Choose first succeeding substituter.
@@ -1566,8 +1566,8 @@ ref<Store> openStore(const std::string & uri_,
throw Error("don't know how to open Nix store '%s'", uri_);
}
std::list<ref<Store>> getDefaultSubstituters()
{
kj::Promise<Result<std::list<ref<Store>>>> getDefaultSubstituters()
try {
static auto stores([]() {
std::list<ref<Store>> stores;
@@ -1592,7 +1592,9 @@ std::list<ref<Store>> getDefaultSubstituters()
return stores;
} ());
return stores;
co_return stores;
} catch (...) {
co_return result::current_exception();
}
std::vector<StoreFactory> * StoreImplementations::registered = 0;
+1 -1
View File
@@ -1008,7 +1008,7 @@ ref<Store> openStore(const std::string & uri = settings.storeUri.get(),
* @return the default substituter stores, defined by the
* substituters option and various legacy options.
*/
std::list<ref<Store>> getDefaultSubstituters();
kj::Promise<Result<std::list<ref<Store>>>> getDefaultSubstituters();
struct StoreFactory
{
+1 -1
View File
@@ -26,7 +26,7 @@ struct CmdLog : InstallableCommand
{
settings.readOnlyMode = true;
auto subs = getDefaultSubstituters();
auto subs = aio().blockOn(getDefaultSubstituters());
subs.push_front(store);