1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 21:01:16 +02:00

Make DerivedPathWithHints a newtype

This allows us to namespace its constructors under it.
This commit is contained in:
John Ericson 2021-04-05 10:05:21 -04:00
parent 9b805d36ac
commit 179582872d
8 changed files with 44 additions and 31 deletions

View file

@ -329,14 +329,14 @@ struct InstallableStorePath : Installable
for (auto & [name, output] : drv.outputsAndOptPaths(*store))
outputs.emplace(name, output.second);
return {
DerivedPathWithHintsBuilt {
DerivedPathWithHints::Built {
.drvPath = storePath,
.outputs = std::move(outputs)
}
};
} else {
return {
DerivedPathOpaque {
DerivedPathWithHints::Opaque {
.path = storePath,
}
};
@ -364,7 +364,7 @@ DerivedPathsWithHints InstallableValue::toDerivedPathsWithHints()
}
for (auto & i : drvsToOutputs)
res.push_back(DerivedPathWithHintsBuilt { i.first, i.second });
res.push_back(DerivedPathWithHints::Built { i.first, i.second });
return res;
}
@ -684,17 +684,17 @@ DerivedPathsWithHints build(ref<Store> store, Realise mode,
for (auto & i : installables) {
for (auto & b : i->toDerivedPathsWithHints()) {
std::visit(overloaded {
[&](DerivedPathOpaque bo) {
[&](DerivedPathWithHints::Opaque bo) {
pathsToBuild.push_back(bo);
},
[&](DerivedPathWithHintsBuilt bfd) {
[&](DerivedPathWithHints::Built bfd) {
StringSet outputNames;
for (auto & output : bfd.outputs)
outputNames.insert(output.first);
pathsToBuild.push_back(
DerivedPath::Built{bfd.drvPath, outputNames});
},
}, b);
}, b.raw());
buildables.push_back(std::move(b));
}
}
@ -717,10 +717,10 @@ std::set<RealisedPath> toRealisedPaths(
if (operateOn == OperateOn::Output) {
for (auto & b : build(store, mode, installables))
std::visit(overloaded {
[&](DerivedPathOpaque bo) {
[&](DerivedPathWithHints::Opaque bo) {
res.insert(bo.path);
},
[&](DerivedPathWithHintsBuilt bfd) {
[&](DerivedPathWithHints::Built bfd) {
auto drv = store->readDerivation(bfd.drvPath);
auto outputHashes = staticOutputHashes(*store, drv);
for (auto & output : bfd.outputs) {
@ -745,14 +745,14 @@ std::set<RealisedPath> toRealisedPaths(
}
}
},
}, b);
}, b.raw());
} else {
if (mode == Realise::Nothing)
settings.readOnlyMode = true;
for (auto & i : installables)
for (auto & b : i->toDerivedPathsWithHints())
if (auto bfd = std::get_if<DerivedPathWithHintsBuilt>(&b))
if (auto bfd = std::get_if<DerivedPathWithHints::Built>(&b))
res.insert(bfd->drvPath);
}
@ -789,7 +789,7 @@ StorePathSet toDerivations(ref<Store> store,
for (auto & i : installables)
for (auto & b : i->toDerivedPathsWithHints())
std::visit(overloaded {
[&](DerivedPathOpaque bo) {
[&](DerivedPathWithHints::Opaque bo) {
if (!useDeriver)
throw Error("argument '%s' did not evaluate to a derivation", i->what());
auto derivers = store->queryValidDerivers(bo.path);
@ -798,10 +798,10 @@ StorePathSet toDerivations(ref<Store> store,
// FIXME: use all derivers?
drvPaths.insert(*derivers.begin());
},
[&](DerivedPathWithHintsBuilt bfd) {
[&](DerivedPathWithHints::Built bfd) {
drvPaths.insert(bfd.drvPath);
},
}, b);
}, b.raw());
return drvPaths;
}