Fix why-depends for CA derivations (again)
This has the same goal as b13fd4c58e81b2b2b0d72caa5ce80de861622610,but achieves it in a different way in order to not break `nix why-depends --derivation`.
This commit is contained in:
parent
6a90ef072c
commit
8cac451fce
|
@ -931,10 +931,7 @@ std::vector<std::pair<std::shared_ptr<Installable>, BuiltPathWithResult>> Instal
|
||||||
DrvOutput outputId { *outputHash, output };
|
DrvOutput outputId { *outputHash, output };
|
||||||
auto realisation = store->queryRealisation(outputId);
|
auto realisation = store->queryRealisation(outputId);
|
||||||
if (!realisation)
|
if (!realisation)
|
||||||
throw Error(
|
throw MissingRealisation(outputId);
|
||||||
"cannot operate on an output of the "
|
|
||||||
"unbuilt derivation '%s'",
|
|
||||||
outputId.to_string());
|
|
||||||
outputs.insert_or_assign(output, realisation->outPath);
|
outputs.insert_or_assign(output, realisation->outPath);
|
||||||
} else {
|
} else {
|
||||||
// If ca-derivations isn't enabled, assume that
|
// If ca-derivations isn't enabled, assume that
|
||||||
|
|
|
@ -93,4 +93,14 @@ struct RealisedPath {
|
||||||
GENERATE_CMP(RealisedPath, me->raw);
|
GENERATE_CMP(RealisedPath, me->raw);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MissingRealisation : public Error
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MissingRealisation(DrvOutput & outputId)
|
||||||
|
: Error( "cannot operate on an output of the "
|
||||||
|
"unbuilt derivation '%s'",
|
||||||
|
outputId.to_string())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -879,10 +879,7 @@ std::vector<BuildResult> RemoteStore::buildPathsWithResults(
|
||||||
auto realisation =
|
auto realisation =
|
||||||
queryRealisation(outputId);
|
queryRealisation(outputId);
|
||||||
if (!realisation)
|
if (!realisation)
|
||||||
throw Error(
|
throw MissingRealisation(outputId);
|
||||||
"cannot operate on an output of unbuilt "
|
|
||||||
"content-addressed derivation '%s'",
|
|
||||||
outputId.to_string());
|
|
||||||
res.builtOutputs.emplace(realisation->id, *realisation);
|
res.builtOutputs.emplace(realisation->id, *realisation);
|
||||||
} else {
|
} else {
|
||||||
// If ca-derivations isn't enabled, assume that
|
// If ca-derivations isn't enabled, assume that
|
||||||
|
|
|
@ -95,19 +95,25 @@ struct CmdWhyDepends : SourceExprCommand
|
||||||
* to build.
|
* to build.
|
||||||
*/
|
*/
|
||||||
auto dependency = parseInstallable(store, _dependency);
|
auto dependency = parseInstallable(store, _dependency);
|
||||||
auto dependencyPath = Installable::toStorePath(getEvalStore(), store, Realise::Derivation, operateOn, dependency);
|
auto optDependencyPath = [&]() -> std::optional<StorePath> {
|
||||||
auto dependencyPathHash = dependencyPath.hashPart();
|
try {
|
||||||
|
return {Installable::toStorePath(getEvalStore(), store, Realise::Derivation, operateOn, dependency)};
|
||||||
|
} catch (MissingRealisation &) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
StorePathSet closure;
|
StorePathSet closure;
|
||||||
store->computeFSClosure({packagePath}, closure, false, false);
|
store->computeFSClosure({packagePath}, closure, false, false);
|
||||||
|
|
||||||
if (!closure.count(dependencyPath)) {
|
if (!optDependencyPath.has_value() || !closure.count(*optDependencyPath)) {
|
||||||
printError("'%s' does not depend on '%s'",
|
printError("'%s' does not depend on '%s'", package->what(), dependency->what());
|
||||||
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();
|
||||||
|
|
Loading…
Reference in a new issue