Revert "Fix why-depends for CA derivations"

This reverts commit b13fd4c58e.
This commit is contained in:
Théophane Hufschmitt 2023-01-02 15:44:04 +01:00
parent 9af16c5f74
commit 105d74eb81

View file

@ -95,35 +95,19 @@ struct CmdWhyDepends : SourceExprCommand
* to build. * to build.
*/ */
auto dependency = parseInstallable(store, _dependency); auto dependency = parseInstallable(store, _dependency);
auto derivedDependency = dependency->toDerivedPath(); auto dependencyPath = Installable::toStorePath(getEvalStore(), store, Realise::Derivation, operateOn, dependency);
auto optDependencyPath = std::visit(overloaded { auto dependencyPathHash = dependencyPath.hashPart();
[](const DerivedPath::Opaque & nodrv) -> std::optional<StorePath> {
return { nodrv.path };
},
[&](const DerivedPath::Built & hasdrv) -> std::optional<StorePath> {
if (hasdrv.outputs.size() != 1) {
throw Error("argument '%s' should evaluate to one store path", dependency->what());
}
auto outputMap = store->queryPartialDerivationOutputMap(hasdrv.drvPath);
auto maybePath = outputMap.find(*hasdrv.outputs.begin());
if (maybePath == outputMap.end()) {
throw Error("unexpected end of iterator");
}
return maybePath->second;
},
}, derivedDependency.raw());
StorePathSet closure; StorePathSet closure;
store->computeFSClosure({packagePath}, closure, false, false); store->computeFSClosure({packagePath}, closure, false, false);
if (!optDependencyPath.has_value() || !closure.count(*optDependencyPath)) { if (!closure.count(dependencyPath)) {
printError("'%s' does not depend on '%s'", package->what(), dependency->what()); printError("'%s' does not depend on '%s'",
store->printStorePath(packagePath),
store->printStorePath(dependencyPath));
return; return;
} }
auto dependencyPath = *optDependencyPath;
auto dependencyPathHash = dependencyPath.hashPart();
stopProgressBar(); // FIXME stopProgressBar(); // FIXME
auto accessor = store->getFSAccessor(); auto accessor = store->getFSAccessor();