aboutsummaryrefslogtreecommitdiff
path: root/src/nix/why-depends.cc
diff options
context:
space:
mode:
authorTaeer Bar-Yam <taeer.bar-yam@tweag.io>2022-11-23 12:06:47 -0500
committerTaeer Bar-Yam <taeer.bar-yam@tweag.io>2022-11-23 12:06:47 -0500
commitbd8571a5c3724ba5917564a5243af173966515c5 (patch)
treece9e35cb22bad39d035e4a79c167d70e831887da /src/nix/why-depends.cc
parentb13fd4c58e81b2b2b0d72caa5ce80de861622610 (diff)
add explanation and test
Diffstat (limited to 'src/nix/why-depends.cc')
-rw-r--r--src/nix/why-depends.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc
index 285e36722..723017497 100644
--- a/src/nix/why-depends.cc
+++ b/src/nix/why-depends.cc
@@ -83,6 +83,17 @@ struct CmdWhyDepends : SourceExprCommand
{
auto package = parseInstallable(store, _package);
auto packagePath = Installable::toStorePath(getEvalStore(), store, Realise::Outputs, operateOn, package);
+
+ /* We don't need to build `dependency`. We try to get the store
+ * path if it's already known, and if not, then it's not a dependency.
+ *
+ * Why? If `package` does depends on `dependency`, then getting the
+ * store path of `package` above necessitated having the store path
+ * of `dependency`. The contrapositive is, if the store path of
+ * `dependency` is not already known at this point (i.e. it's a CA
+ * derivation which hasn't been built), then `package` did not need it
+ * to build.
+ */
auto dependency = parseInstallable(store, _dependency);
auto derivedDependency = dependency->toDerivedPath();
auto optDependencyPath = std::visit(overloaded {