mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
Rename Buildable
This commit is contained in:
parent
9dfb97c987
commit
9b805d36ac
35 changed files with 165 additions and 162 deletions
|
@ -162,7 +162,7 @@ void MixProfile::updateProfile(const StorePath & storePath)
|
|||
profile2, storePath));
|
||||
}
|
||||
|
||||
void MixProfile::updateProfile(const Buildables & buildables)
|
||||
void MixProfile::updateProfile(const DerivedPathsWithHints & buildables)
|
||||
{
|
||||
if (!profile) return;
|
||||
|
||||
|
@ -170,10 +170,10 @@ void MixProfile::updateProfile(const Buildables & buildables)
|
|||
|
||||
for (auto & buildable : buildables) {
|
||||
std::visit(overloaded {
|
||||
[&](BuildableOpaque bo) {
|
||||
[&](DerivedPathOpaque bo) {
|
||||
result.push_back(bo.path);
|
||||
},
|
||||
[&](BuildableFromDrv bfd) {
|
||||
[&](DerivedPathWithHintsBuilt bfd) {
|
||||
for (auto & output : bfd.outputs) {
|
||||
/* Output path should be known because we just tried to
|
||||
build it. */
|
||||
|
|
|
@ -216,7 +216,7 @@ static RegisterCommand registerCommand2(std::vector<std::string> && name)
|
|||
return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
|
||||
}
|
||||
|
||||
Buildables build(ref<Store> store, Realise mode,
|
||||
DerivedPathsWithHints build(ref<Store> store, Realise mode,
|
||||
std::vector<std::shared_ptr<Installable>> installables, BuildMode bMode = bmNormal);
|
||||
|
||||
std::set<StorePath> toStorePaths(ref<Store> store,
|
||||
|
@ -252,7 +252,7 @@ struct MixProfile : virtual StoreCommand
|
|||
|
||||
/* If 'profile' is set, make it point at the store path produced
|
||||
by 'buildables'. */
|
||||
void updateProfile(const Buildables & buildables);
|
||||
void updateProfile(const DerivedPathsWithHints & buildables);
|
||||
};
|
||||
|
||||
struct MixDefaultProfile : MixProfile
|
||||
|
|
|
@ -285,9 +285,9 @@ void completeFlakeRef(ref<Store> store, std::string_view prefix)
|
|||
}
|
||||
}
|
||||
|
||||
Buildable Installable::toBuildable()
|
||||
DerivedPathWithHints Installable::toDerivedPathWithHints()
|
||||
{
|
||||
auto buildables = toBuildables();
|
||||
auto buildables = toDerivedPathsWithHints();
|
||||
if (buildables.size() != 1)
|
||||
throw Error("installable '%s' evaluates to %d derivations, where only one is expected", what(), buildables.size());
|
||||
return std::move(buildables[0]);
|
||||
|
@ -321,7 +321,7 @@ struct InstallableStorePath : Installable
|
|||
|
||||
std::string what() override { return store->printStorePath(storePath); }
|
||||
|
||||
Buildables toBuildables() override
|
||||
DerivedPathsWithHints toDerivedPathsWithHints() override
|
||||
{
|
||||
if (storePath.isDerivation()) {
|
||||
std::map<std::string, std::optional<StorePath>> outputs;
|
||||
|
@ -329,14 +329,14 @@ struct InstallableStorePath : Installable
|
|||
for (auto & [name, output] : drv.outputsAndOptPaths(*store))
|
||||
outputs.emplace(name, output.second);
|
||||
return {
|
||||
BuildableFromDrv {
|
||||
DerivedPathWithHintsBuilt {
|
||||
.drvPath = storePath,
|
||||
.outputs = std::move(outputs)
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
BuildableOpaque {
|
||||
DerivedPathOpaque {
|
||||
.path = storePath,
|
||||
}
|
||||
};
|
||||
|
@ -349,9 +349,9 @@ struct InstallableStorePath : Installable
|
|||
}
|
||||
};
|
||||
|
||||
Buildables InstallableValue::toBuildables()
|
||||
DerivedPathsWithHints InstallableValue::toDerivedPathsWithHints()
|
||||
{
|
||||
Buildables res;
|
||||
DerivedPathsWithHints res;
|
||||
|
||||
std::map<StorePath, std::map<std::string, std::optional<StorePath>>> drvsToOutputs;
|
||||
|
||||
|
@ -364,7 +364,7 @@ Buildables InstallableValue::toBuildables()
|
|||
}
|
||||
|
||||
for (auto & i : drvsToOutputs)
|
||||
res.push_back(BuildableFromDrv { i.first, i.second });
|
||||
res.push_back(DerivedPathWithHintsBuilt { i.first, i.second });
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -671,28 +671,28 @@ std::shared_ptr<Installable> SourceExprCommand::parseInstallable(
|
|||
return installables.front();
|
||||
}
|
||||
|
||||
Buildables build(ref<Store> store, Realise mode,
|
||||
DerivedPathsWithHints build(ref<Store> store, Realise mode,
|
||||
std::vector<std::shared_ptr<Installable>> installables, BuildMode bMode)
|
||||
{
|
||||
if (mode == Realise::Nothing)
|
||||
settings.readOnlyMode = true;
|
||||
|
||||
Buildables buildables;
|
||||
DerivedPathsWithHints buildables;
|
||||
|
||||
std::vector<BuildableReq> pathsToBuild;
|
||||
std::vector<DerivedPath> pathsToBuild;
|
||||
|
||||
for (auto & i : installables) {
|
||||
for (auto & b : i->toBuildables()) {
|
||||
for (auto & b : i->toDerivedPathsWithHints()) {
|
||||
std::visit(overloaded {
|
||||
[&](BuildableOpaque bo) {
|
||||
[&](DerivedPathOpaque bo) {
|
||||
pathsToBuild.push_back(bo);
|
||||
},
|
||||
[&](BuildableFromDrv bfd) {
|
||||
[&](DerivedPathWithHintsBuilt bfd) {
|
||||
StringSet outputNames;
|
||||
for (auto & output : bfd.outputs)
|
||||
outputNames.insert(output.first);
|
||||
pathsToBuild.push_back(
|
||||
BuildableReqFromDrv{bfd.drvPath, outputNames});
|
||||
DerivedPath::Built{bfd.drvPath, outputNames});
|
||||
},
|
||||
}, b);
|
||||
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 {
|
||||
[&](BuildableOpaque bo) {
|
||||
[&](DerivedPathOpaque bo) {
|
||||
res.insert(bo.path);
|
||||
},
|
||||
[&](BuildableFromDrv bfd) {
|
||||
[&](DerivedPathWithHintsBuilt bfd) {
|
||||
auto drv = store->readDerivation(bfd.drvPath);
|
||||
auto outputHashes = staticOutputHashes(*store, drv);
|
||||
for (auto & output : bfd.outputs) {
|
||||
|
@ -751,8 +751,8 @@ std::set<RealisedPath> toRealisedPaths(
|
|||
settings.readOnlyMode = true;
|
||||
|
||||
for (auto & i : installables)
|
||||
for (auto & b : i->toBuildables())
|
||||
if (auto bfd = std::get_if<BuildableFromDrv>(&b))
|
||||
for (auto & b : i->toDerivedPathsWithHints())
|
||||
if (auto bfd = std::get_if<DerivedPathWithHintsBuilt>(&b))
|
||||
res.insert(bfd->drvPath);
|
||||
}
|
||||
|
||||
|
@ -787,9 +787,9 @@ StorePathSet toDerivations(ref<Store> store,
|
|||
StorePathSet drvPaths;
|
||||
|
||||
for (auto & i : installables)
|
||||
for (auto & b : i->toBuildables())
|
||||
for (auto & b : i->toDerivedPathsWithHints())
|
||||
std::visit(overloaded {
|
||||
[&](BuildableOpaque bo) {
|
||||
[&](DerivedPathOpaque bo) {
|
||||
if (!useDeriver)
|
||||
throw Error("argument '%s' did not evaluate to a derivation", i->what());
|
||||
auto derivers = store->queryValidDerivers(bo.path);
|
||||
|
@ -798,7 +798,7 @@ StorePathSet toDerivations(ref<Store> store,
|
|||
// FIXME: use all derivers?
|
||||
drvPaths.insert(*derivers.begin());
|
||||
},
|
||||
[&](BuildableFromDrv bfd) {
|
||||
[&](DerivedPathWithHintsBuilt bfd) {
|
||||
drvPaths.insert(bfd.drvPath);
|
||||
},
|
||||
}, b);
|
||||
|
|
|
@ -29,9 +29,9 @@ struct Installable
|
|||
|
||||
virtual std::string what() = 0;
|
||||
|
||||
virtual Buildables toBuildables() = 0;
|
||||
virtual DerivedPathsWithHints toDerivedPathsWithHints() = 0;
|
||||
|
||||
Buildable toBuildable();
|
||||
DerivedPathWithHints toDerivedPathWithHints();
|
||||
|
||||
App toApp(EvalState & state);
|
||||
|
||||
|
@ -74,7 +74,7 @@ struct InstallableValue : Installable
|
|||
|
||||
virtual std::vector<DerivationInfo> toDerivations() = 0;
|
||||
|
||||
Buildables toBuildables() override;
|
||||
DerivedPathsWithHints toDerivedPathsWithHints() override;
|
||||
};
|
||||
|
||||
struct InstallableFlake : InstallableValue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue