aboutsummaryrefslogtreecommitdiff
path: root/src/nix/why-depends.cc
diff options
context:
space:
mode:
authorThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2023-01-02 15:44:04 +0100
committerThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2023-01-02 15:44:04 +0100
commit105d74eb8177016a1056b6642875c318a148a776 (patch)
treed209f86ac484e62ca20cec4f6f9dea0ec5a15f88 /src/nix/why-depends.cc
parent9af16c5f742300e831a2cc400e43df1e22f87f31 (diff)
Revert "Fix why-depends for CA derivations"
This reverts commit b13fd4c58e81b2b2b0d72caa5ce80de861622610.
Diffstat (limited to 'src/nix/why-depends.cc')
-rw-r--r--src/nix/why-depends.cc28
1 files 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<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());
+ 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();