mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Clean up app.cc
(#9201)
- Rename `expected` to `expectedType` - Use early `return` and `continue` to reduce nesting
This commit is contained in:
parent
edc07588ec
commit
201a4af9a4
2 changed files with 24 additions and 18 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -138,7 +138,9 @@ nix-rust/target
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
||||||
|
# IDE
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
# clangd and possibly more
|
# clangd and possibly more
|
||||||
.cache/
|
.cache/
|
||||||
|
|
|
@ -20,20 +20,24 @@ StringPairs resolveRewrites(
|
||||||
const std::vector<BuiltPathWithResult> & dependencies)
|
const std::vector<BuiltPathWithResult> & dependencies)
|
||||||
{
|
{
|
||||||
StringPairs res;
|
StringPairs res;
|
||||||
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
if (!experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
||||||
for (auto & dep : dependencies) {
|
return res;
|
||||||
if (auto drvDep = std::get_if<BuiltPathBuilt>(&dep.path)) {
|
}
|
||||||
for (auto & [ outputName, outputPath ] : drvDep->outputs) {
|
for (auto &dep: dependencies) {
|
||||||
res.emplace(
|
auto drvDep = std::get_if<BuiltPathBuilt>(&dep.path);
|
||||||
DownstreamPlaceholder::fromSingleDerivedPathBuilt(
|
if (!drvDep) {
|
||||||
SingleDerivedPath::Built {
|
continue;
|
||||||
.drvPath = make_ref<SingleDerivedPath>(drvDep->drvPath->discardOutputPath()),
|
}
|
||||||
.output = outputName,
|
|
||||||
}).render(),
|
for (const auto & [ outputName, outputPath ] : drvDep->outputs) {
|
||||||
store.printStorePath(outputPath)
|
res.emplace(
|
||||||
);
|
DownstreamPlaceholder::fromSingleDerivedPathBuilt(
|
||||||
}
|
SingleDerivedPath::Built {
|
||||||
}
|
.drvPath = make_ref<SingleDerivedPath>(drvDep->drvPath->discardOutputPath()),
|
||||||
|
.output = outputName,
|
||||||
|
}).render(),
|
||||||
|
store.printStorePath(outputPath)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -58,11 +62,11 @@ UnresolvedApp InstallableValue::toApp(EvalState & state)
|
||||||
|
|
||||||
auto type = cursor->getAttr("type")->getString();
|
auto type = cursor->getAttr("type")->getString();
|
||||||
|
|
||||||
std::string expected = !attrPath.empty() &&
|
std::string expectedType = !attrPath.empty() &&
|
||||||
(state.symbols[attrPath[0]] == "apps" || state.symbols[attrPath[0]] == "defaultApp")
|
(state.symbols[attrPath[0]] == "apps" || state.symbols[attrPath[0]] == "defaultApp")
|
||||||
? "app" : "derivation";
|
? "app" : "derivation";
|
||||||
if (type != expected)
|
if (type != expectedType)
|
||||||
throw Error("attribute '%s' should have type '%s'", cursor->getAttrPathStr(), expected);
|
throw Error("attribute '%s' should have type '%s'", cursor->getAttrPathStr(), expectedType);
|
||||||
|
|
||||||
if (type == "app") {
|
if (type == "app") {
|
||||||
auto [program, context] = cursor->getAttr("program")->getStringWithContext();
|
auto [program, context] = cursor->getAttr("program")->getStringWithContext();
|
||||||
|
@ -91,7 +95,7 @@ UnresolvedApp InstallableValue::toApp(EvalState & state)
|
||||||
}, c.raw));
|
}, c.raw));
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnresolvedApp{App {
|
return UnresolvedApp { App {
|
||||||
.context = std::move(context2),
|
.context = std::move(context2),
|
||||||
.program = program,
|
.program = program,
|
||||||
}};
|
}};
|
||||||
|
|
Loading…
Reference in a new issue