libcmd: asyncify ProfileManifest::build
Change-Id: Ib1d7ce47c81259d305f3e993618516e4c165a084
This commit is contained in:
@@ -223,8 +223,8 @@ nlohmann::json ProfileManifest::toJSON(Store & store) const
|
||||
return json;
|
||||
}
|
||||
|
||||
StorePath ProfileManifest::build(ref<Store> store)
|
||||
{
|
||||
kj::Promise<Result<StorePath>> ProfileManifest::build(ref<Store> store)
|
||||
try {
|
||||
auto tempDir = createTempDir();
|
||||
|
||||
StorePathSet references;
|
||||
@@ -269,7 +269,9 @@ StorePath ProfileManifest::build(ref<Store> store)
|
||||
StringSource source(sink.s);
|
||||
store->addToStore(info, source);
|
||||
|
||||
return std::move(info.path);
|
||||
co_return std::move(info.path);
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
void ProfileManifest::printDiff(
|
||||
|
||||
@@ -64,7 +64,7 @@ struct ProfileManifest
|
||||
|
||||
nlohmann::json toJSON(Store & store) const;
|
||||
|
||||
StorePath build(ref<Store> store);
|
||||
kj::Promise<Result<StorePath>> build(ref<Store> store);
|
||||
|
||||
void addElement(std::string_view nameCandidate, ProfileElement element);
|
||||
void addElement(ProfileElement element);
|
||||
|
||||
+3
-3
@@ -110,7 +110,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
|
||||
}
|
||||
|
||||
try {
|
||||
updateProfile(manifest.build(store));
|
||||
updateProfile(aio().blockOn(manifest.build(store)));
|
||||
} catch (BuildEnvFileConflictError & conflictError) {
|
||||
// FIXME use C++20 std::ranges once macOS has it
|
||||
// See https://github.com/NixOS/nix/compare/3efa476c5439f8f6c1968a6ba20a31d1239c2f04..1fe5d172ece51a619e879c4b86f603d9495cc102
|
||||
@@ -270,7 +270,7 @@ struct CmdProfileRemove : virtual EvalCommand, MixDefaultProfile, MixProfileElem
|
||||
}
|
||||
warn ("Use 'nix profile list' to see the current profile.");
|
||||
}
|
||||
updateProfile(newManifest.build(store));
|
||||
updateProfile(aio().blockOn(newManifest.build(store)));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -406,7 +406,7 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf
|
||||
builtPaths.find(&*installable)->second.first);
|
||||
}
|
||||
|
||||
updateProfile(manifest.build(store));
|
||||
updateProfile(aio().blockOn(manifest.build(store)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand
|
||||
manifest.elements.at(nixElemName) = elemForNewNix;
|
||||
|
||||
// Build the new profile, and switch to it.
|
||||
StorePath const newProfile = manifest.build(store);
|
||||
StorePath const newProfile = aio().blockOn(manifest.build(store));
|
||||
printTalkative("built new profile '%s'", store->printStorePath(newProfile));
|
||||
auto const newGeneration =
|
||||
aio().blockOn(createGeneration(*fsStore, this->profileDir, newProfile));
|
||||
|
||||
Reference in New Issue
Block a user