1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-17 07:52:43 +01:00

Enfore the use of properly built paths in libcmd

Replace `DerivedPathWithHints` by a new `BuiltPath` type that serves as
a proof that the corresponding path has been built.
This commit is contained in:
regnat 2021-05-17 08:45:08 +02:00
parent ec613603ba
commit 2105084645
10 changed files with 189 additions and 144 deletions

View file

@ -265,9 +265,9 @@ struct Common : InstallableCommand, MixProfile
for (auto & [installable_, dir_] : redirects) {
auto dir = absPath(dir_);
auto installable = parseInstallable(store, installable_);
auto buildable = installable->toBuiltPath();
auto doRedirect = [&](const StorePath & path)
{
auto builtPaths = toStorePaths(
store, Realise::Nothing, OperateOn::Output, {installable});
for (auto & path: builtPaths) {
auto from = store->printStorePath(path);
if (script.find(from) == std::string::npos)
warn("'%s' (path '%s') is not used by this build environment", installable->what(), from);
@ -275,16 +275,7 @@ struct Common : InstallableCommand, MixProfile
printInfo("redirecting '%s' to '%s'", from, dir);
rewrites.insert({from, dir});
}
};
std::visit(overloaded {
[&](const BuiltPath::Opaque & bo) {
doRedirect(bo.path);
},
[&](const BuiltPath::Built & bfd) {
for (auto & [outputName, path] : bfd.outputs)
if (path) doRedirect(*path);
},
}, buildable.raw());
}
}
return rewriteStrings(script, rewrites);