mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Merge pull request #7539 from tweag/fix-nix-why-depends--derivation
Fix `nix why-depends --derivation`
This commit is contained in:
commit
0fe2b222d5
6 changed files with 23 additions and 25 deletions
|
@ -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,23 +95,13 @@ struct CmdWhyDepends : SourceExprCommand
|
||||||
* to build.
|
* to build.
|
||||||
*/
|
*/
|
||||||
auto dependency = parseInstallable(store, _dependency);
|
auto dependency = parseInstallable(store, _dependency);
|
||||||
auto derivedDependency = dependency->toDerivedPath();
|
auto optDependencyPath = [&]() -> std::optional<StorePath> {
|
||||||
auto optDependencyPath = std::visit(overloaded {
|
try {
|
||||||
[](const DerivedPath::Opaque & nodrv) -> std::optional<StorePath> {
|
return {Installable::toStorePath(getEvalStore(), store, Realise::Derivation, operateOn, dependency)};
|
||||||
return { nodrv.path };
|
} catch (MissingRealisation &) {
|
||||||
},
|
return std::nullopt;
|
||||||
[&](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);
|
||||||
|
|
|
@ -92,6 +92,7 @@ nix_tests = \
|
||||||
fmt.sh \
|
fmt.sh \
|
||||||
eval-store.sh \
|
eval-store.sh \
|
||||||
why-depends.sh \
|
why-depends.sh \
|
||||||
|
ca/why-depends.sh \
|
||||||
import-derivation.sh \
|
import-derivation.sh \
|
||||||
ca/import-derivation.sh \
|
ca/import-derivation.sh \
|
||||||
nix_path.sh \
|
nix_path.sh \
|
||||||
|
|
|
@ -6,6 +6,9 @@ cp ./dependencies.nix ./dependencies.builder0.sh ./config.nix $TEST_HOME
|
||||||
|
|
||||||
cd $TEST_HOME
|
cd $TEST_HOME
|
||||||
|
|
||||||
|
nix why-depends --derivation --file ./dependencies.nix input2_drv input1_drv
|
||||||
|
nix why-depends --file ./dependencies.nix input2_drv input1_drv
|
||||||
|
|
||||||
nix-build ./dependencies.nix -A input0_drv -o dep
|
nix-build ./dependencies.nix -A input0_drv -o dep
|
||||||
nix-build ./dependencies.nix -o toplevel
|
nix-build ./dependencies.nix -o toplevel
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue