mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
add layers to catching IFDs in nix flake show
This commit is contained in:
parent
68839b9545
commit
68987761ef
1 changed files with 31 additions and 9 deletions
|
|
@ -1153,10 +1153,15 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
|||
if ((attrPathS[0] == "apps" || attrPathS[0] == "checks" || attrPathS[0] == "devShells"
|
||||
|| attrPathS[0] == "legacyPackages" || attrPathS[0] == "packages")
|
||||
&& (attrPathS.size() == 1 || attrPathS.size() == 2)) {
|
||||
for (const auto & subAttr : visitor2->getAttrs()) {
|
||||
if (hasContent(*visitor2, attrPath2, subAttr)) {
|
||||
return true;
|
||||
try {
|
||||
for (const auto & subAttr : visitor2->getAttrs()) {
|
||||
if (hasContent(*visitor2, attrPath2, subAttr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (IFDError & e) {
|
||||
// allow IFD errors here; as we handle them during `visit()`
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1164,10 +1169,14 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
|||
if ((attrPathS.size() == 1)
|
||||
&& (attrPathS[0] == "formatter" || attrPathS[0] == "nixosConfigurations"
|
||||
|| attrPathS[0] == "nixosModules" || attrPathS[0] == "overlays")) {
|
||||
for (const auto & subAttr : visitor2->getAttrs()) {
|
||||
if (hasContent(*visitor2, attrPath2, subAttr)) {
|
||||
return true;
|
||||
try {
|
||||
for (const auto & subAttr : visitor2->getAttrs()) {
|
||||
if (hasContent(*visitor2, attrPath2, subAttr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (IFDError & e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1204,9 +1213,22 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
|||
if (!json)
|
||||
logger->cout("%s", headerPrefix);
|
||||
std::vector<Symbol> attrs;
|
||||
for (const auto & attr : visitor.getAttrs()) {
|
||||
if (hasContent(visitor, attrPath, attr))
|
||||
attrs.push_back(attr);
|
||||
try {
|
||||
for (const auto & attr : visitor.getAttrs()) {
|
||||
if (hasContent(visitor, attrPath, attr))
|
||||
attrs.push_back(attr);
|
||||
}
|
||||
if (!json)
|
||||
logger->cout("%s", headerPrefix);
|
||||
} catch (IFDError & e) {
|
||||
if (!json) {
|
||||
logger->cout(
|
||||
fmt("%s " ANSI_WARNING "omitted due to use of import from derivation" ANSI_NORMAL,
|
||||
headerPrefix));
|
||||
} else {
|
||||
logger->warn(fmt(
|
||||
"%s omitted due to use of import from derivation", concatStringsSep(".", attrPathS)));
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto & [i, attr] : enumerate(attrs)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue