From 105d74eb8177016a1056b6642875c318a148a776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 2 Jan 2023 15:44:04 +0100 Subject: [PATCH] Revert "Fix why-depends for CA derivations" This reverts commit b13fd4c58e81b2b2b0d72caa5ce80de861622610. --- src/nix/why-depends.cc | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc index 723017497..6512aee03 100644 --- a/src/nix/why-depends.cc +++ b/src/nix/why-depends.cc @@ -95,35 +95,19 @@ struct CmdWhyDepends : SourceExprCommand * to build. */ auto dependency = parseInstallable(store, _dependency); - auto derivedDependency = dependency->toDerivedPath(); - auto optDependencyPath = std::visit(overloaded { - [](const DerivedPath::Opaque & nodrv) -> std::optional { - return { nodrv.path }; - }, - [&](const DerivedPath::Built & hasdrv) -> std::optional { - 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()); + auto dependencyPath = Installable::toStorePath(getEvalStore(), store, Realise::Derivation, operateOn, dependency); + auto dependencyPathHash = dependencyPath.hashPart(); StorePathSet closure; store->computeFSClosure({packagePath}, closure, false, false); - if (!optDependencyPath.has_value() || !closure.count(*optDependencyPath)) { - printError("'%s' does not depend on '%s'", package->what(), dependency->what()); + if (!closure.count(dependencyPath)) { + printError("'%s' does not depend on '%s'", + store->printStorePath(packagePath), + store->printStorePath(dependencyPath)); return; } - auto dependencyPath = *optDependencyPath; - auto dependencyPathHash = dependencyPath.hashPart(); - stopProgressBar(); // FIXME auto accessor = store->getFSAccessor();