mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Merge 5c32923397 into 479b6b73a9
This commit is contained in:
commit
bd897a69d1
3 changed files with 35 additions and 9 deletions
|
|
@ -1165,10 +1165,15 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
if ((attrPathS[0] == "apps" || attrPathS[0] == "checks" || attrPathS[0] == "devShells"
|
if ((attrPathS[0] == "apps" || attrPathS[0] == "checks" || attrPathS[0] == "devShells"
|
||||||
|| attrPathS[0] == "legacyPackages" || attrPathS[0] == "packages")
|
|| attrPathS[0] == "legacyPackages" || attrPathS[0] == "packages")
|
||||||
&& (attrPathS.size() == 1 || attrPathS.size() == 2)) {
|
&& (attrPathS.size() == 1 || attrPathS.size() == 2)) {
|
||||||
for (const auto & subAttr : visitor2->getAttrs()) {
|
try {
|
||||||
if (hasContent(*visitor2, attrPath2, subAttr)) {
|
for (const auto & subAttr : visitor2->getAttrs()) {
|
||||||
return true;
|
if (hasContent(*visitor2, attrPath2, subAttr)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (IFDError & e) {
|
||||||
|
// allow IFD errors here; as we handle them during `visit()`
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1176,10 +1181,14 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
if ((attrPathS.size() == 1)
|
if ((attrPathS.size() == 1)
|
||||||
&& (attrPathS[0] == "formatter" || attrPathS[0] == "nixosConfigurations"
|
&& (attrPathS[0] == "formatter" || attrPathS[0] == "nixosConfigurations"
|
||||||
|| attrPathS[0] == "nixosModules" || attrPathS[0] == "overlays")) {
|
|| attrPathS[0] == "nixosModules" || attrPathS[0] == "overlays")) {
|
||||||
for (const auto & subAttr : visitor2->getAttrs()) {
|
try {
|
||||||
if (hasContent(*visitor2, attrPath2, subAttr)) {
|
for (const auto & subAttr : visitor2->getAttrs()) {
|
||||||
return true;
|
if (hasContent(*visitor2, attrPath2, subAttr)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (IFDError & e) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1216,9 +1225,22 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
if (!json)
|
if (!json)
|
||||||
logger->cout("%s", headerPrefix);
|
logger->cout("%s", headerPrefix);
|
||||||
std::vector<Symbol> attrs;
|
std::vector<Symbol> attrs;
|
||||||
for (const auto & attr : visitor.getAttrs()) {
|
try {
|
||||||
if (hasContent(visitor, attrPath, attr))
|
for (const auto & attr : visitor.getAttrs()) {
|
||||||
attrs.push_back(attr);
|
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)) {
|
for (const auto & [i, attr] : enumerate(attrs)) {
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ writeIfdFlake() {
|
||||||
{
|
{
|
||||||
outputs = { self }: {
|
outputs = { self }: {
|
||||||
packages.$system.default = import ./ifd.nix;
|
packages.$system.default = import ./ifd.nix;
|
||||||
|
checks.$system = import ./ifd.nix;
|
||||||
|
formatter = import ./ifd.nix;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
|
||||||
|
|
@ -105,5 +105,7 @@ nix eval --impure --expr '
|
||||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||||
in
|
in
|
||||||
assert show_output.packages.${builtins.currentSystem}.default == { };
|
assert show_output.packages.${builtins.currentSystem}.default == { };
|
||||||
|
assert show_output.checks.${builtins.currentSystem} == { };
|
||||||
|
assert show_output.formatter == { };
|
||||||
true
|
true
|
||||||
'
|
'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue