Skip to content

Commit

Permalink
Revert "TEMP"
Browse files Browse the repository at this point in the history
This reverts commit f0810ff16d883dd6d0b499e754ac473ed2fe66a8.
  • Loading branch information
Ericson2314 committed Aug 4, 2023
1 parent 0809f82 commit 069430b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libcmd/installables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,14 @@ StorePathSet Installable::toDerivations(
: throw Error("argument '%s' did not evaluate to a derivation", i->what()));
},
[&](const DerivedPath::Built & bfd) {
drvPaths.insert(resolveDerivedPath(*store, *bfd.drvPath));
drvPaths.insert(std::visit(overloaded {
[&](const SingleDerivedPath::Opaque o) -> StorePath {
return o.path;
},
[&](const SingleDerivedPath::Built b) -> StorePath {
throw Error("argument '%s' did not evaluate to output of dynamic derivation '%s' which is not yet built.", i->what(), b.to_string(*store));
},
}, tryResolveDerivedPath(*store, *bfd.drvPath).raw()));
},
}, b.path.raw());

Expand Down
38 changes: 38 additions & 0 deletions src/libstore/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,44 @@ OutputPathMap resolveDerivedPath(Store & store, const DerivedPath::Built & bfd,
}


SingleDerivedPath tryResolveDerivedPath(Store & store, const SingleDerivedPath & req, Store * evalStore_)
{
auto & evalStore = evalStore_ ? *evalStore_ : store;

return std::visit(overloaded {
[&](const SingleDerivedPath::Opaque &) -> SingleDerivedPath {
return req;
},
[&](const SingleDerivedPath::Built & bfd0) -> SingleDerivedPath {
SingleDerivedPath::Built bfd {
make_ref<SingleDerivedPath>(tryResolveDerivedPath(store, *bfd0.drvPath, evalStore_)),
bfd0.output,
};
return std::visit(overloaded {
[&](const SingleDerivedPath::Opaque & bo) -> SingleDerivedPath {
auto & drvPath = bo.path;
auto outputPaths = evalStore.queryPartialDerivationOutputMap(drvPath, evalStore_);
if (outputPaths.count(bfd.output) == 0)
throw Error("derivation '%s' does not have an output named '%s'",
bfd0.drvPath->to_string(store), bfd.output);
auto & optPath = outputPaths.at(bfd.output);
if (optPath)
// Can resolve this step
return DerivedPath::Opaque { *optPath };
else
// Can't resolve this step
return bfd;
},
[&](const SingleDerivedPath::Built & _) -> SingleDerivedPath {
// Can't resolve previous step, and thus all future steps.
return bfd;
},
}, bfd.drvPath->raw());
},
}, req.raw());
}


StorePath resolveDerivedPath(Store & store, const SingleDerivedPath & req, Store * evalStore_)
{
auto & evalStore = evalStore_ ? *evalStore_ : store;
Expand Down
7 changes: 7 additions & 0 deletions src/libstore/store-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,13 @@ void copyClosure(
void removeTempRoots();


/**
* Attempt to recursively replace derivation outputs with produced paths as
* much as possible, but where the derivation resolution doesn't exists, leave
* as-is.
*/
SingleDerivedPath tryResolveDerivedPath(Store &, const SingleDerivedPath &, Store * evalStore = nullptr);

/**
* Resolve the derived path completely, failing if any derivation output
* is unknown.
Expand Down

0 comments on commit 069430b

Please sign in to comment.