treewide: don't resolveDerivedPath opaque paths

resolution of opaque paths is just an expensive `->path`.

Change-Id: I0c8d8b908f358d0bd26d1dcba84b2de6cbdc7c29
This commit is contained in:
eldritch horrors
2025-05-12 13:37:54 +02:00
parent f5e2e78266
commit 68dfcfc6a4
6 changed files with 9 additions and 15 deletions
+1 -1
View File
@@ -759,7 +759,7 @@ StorePathSet Installable::toDerivations(
: throw Error("argument '%s' did not evaluate to a derivation", i->what()));
},
[&](const DerivedPath::Built & bfd) {
drvPaths.insert(state.aio.blockOn(resolveDerivedPath(*store, *bfd.drvPath)));
drvPaths.insert(bfd.drvPath->path);
},
}, b.path.raw());
+1 -3
View File
@@ -127,9 +127,7 @@ void prim_getContext(EvalState & state, Value * * args, Value & v)
contextInfos[std::move(d.drvPath)].allOutputs = true;
},
[&](NixStringContextElem::Built && b) {
// FIXME should eventually show string context as is, no
// resolving here.
auto drvPath = state.aio.blockOn(resolveDerivedPath(*state.ctx.store, *b.drvPath));
auto drvPath = b.drvPath->path;
contextInfos[std::move(drvPath)].outputs.emplace_back(std::move(b.output));
},
[&](NixStringContextElem::Opaque && o) {
+1 -4
View File
@@ -40,10 +40,7 @@ try {
res["drvPath"] = TRY_AWAIT(drvPath->toJSON(store));
// Fallback for the input-addressed derivation case: We expect to always be
// able to print the output paths, so lets do it
// FIXME try-resolve on drvPath
const auto outputMap = TRY_AWAIT(
store.queryPartialDerivationOutputMap(TRY_AWAIT(resolveDerivedPath(store, *drvPath)))
);
const auto outputMap = TRY_AWAIT(store.queryPartialDerivationOutputMap(drvPath->path));
for (const auto & [output, outputPathOpt] : outputMap) {
if (!outputs.contains(output)) continue;
if (outputPathOpt)
+2 -2
View File
@@ -474,7 +474,7 @@ try {
kj::Promise<Result<OutputPathMap>>
resolveDerivedPath(Store & store, const DerivedPath::Built & bfd, Store * evalStore_)
try {
auto drvPath = TRY_AWAIT(resolveDerivedPath(store, *bfd.drvPath, evalStore_));
auto drvPath = bfd.drvPath->path;
auto outputsOpt_ = TRY_AWAIT(store.queryPartialDerivationOutputMap(drvPath, evalStore_));
@@ -523,7 +523,7 @@ try {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
[&](const SingleDerivedPath::Built & bfd) -> kj::Promise<Result<StorePath>> {
try {
auto drvPath = TRY_AWAIT(resolveDerivedPath(store, *bfd.drvPath, evalStore_));
auto drvPath = bfd.drvPath->path;
auto outputPaths =
TRY_AWAIT(evalStore.queryPartialDerivationOutputMap(drvPath, evalStore_));
if (outputPaths.count(bfd.output) == 0)
+1 -1
View File
@@ -748,7 +748,7 @@ try {
};
OutputPathMap outputs;
auto drvPath = TRY_AWAIT(resolveDerivedPath(*evalStore, *bfd.drvPath));
auto drvPath = bfd.drvPath->path;
auto drv = TRY_AWAIT(evalStore->readDerivation(drvPath));
const auto outputHashes =
TRY_AWAIT(staticOutputHashes(*evalStore, drv)); // FIXME: expensive
+3 -4
View File
@@ -34,15 +34,14 @@ struct CmdLog : InstallableCommand
auto b = installable->toDerivedPath(*getEvaluator()->begin(aio()));
// For compat with CLI today, TODO revisit
auto oneUp = std::visit(overloaded {
auto path = std::visit(overloaded {
[&](const DerivedPath::Opaque & bo) {
return make_ref<SingleDerivedPath::Opaque>(bo);
return bo.path;
},
[&](const DerivedPath::Built & bfd) {
return bfd.drvPath;
return bfd.drvPath->path;
},
}, b.path.raw());
auto path = aio().blockOn(resolveDerivedPath(*store, *oneUp));
RunPager pager;
for (auto & sub : subs) {