modules: Add visible = "shallow" to hide only sub-options

Changed files
+7 -3
lib
+7 -3
lib/options.nix
···
apply ? null,
# Whether the option is for NixOS developers only.
internal ? null,
-
# Whether the option shows up in the manual.
visible ? null,
# Whether the option can be set only once
readOnly ? null,
···
description = opt.description or (lib.warn "Option `${name}' has no description." "This option has no description.");
declarations = filter (x: x != unknownModule) opt.declarations;
internal = opt.internal or false;
-
visible = opt.visible or true;
readOnly = opt.readOnly or false;
type = opt.type.description or null;
}
···
subOptions =
let ss = opt.type.getSubOptions opt.loc;
in if ss != {} then optionAttrSetToDocList' opt.loc ss else [];
in
-
[ docOption ] ++ optionals docOption.visible subOptions) (collect isOption options);
/* This function recursively removes all derivation attributes from
···
apply ? null,
# Whether the option is for NixOS developers only.
internal ? null,
+
# Whether the option shows up in the manual. Default: true. Use false to hide the option and any sub-options from submodules. Use "shallow" to hide only sub-options.
visible ? null,
# Whether the option can be set only once
readOnly ? null,
···
description = opt.description or (lib.warn "Option `${name}' has no description." "This option has no description.");
declarations = filter (x: x != unknownModule) opt.declarations;
internal = opt.internal or false;
+
visible =
+
if (opt?visible && opt.visible == "shallow")
+
then true
+
else opt.visible or true;
readOnly = opt.readOnly or false;
type = opt.type.description or null;
}
···
subOptions =
let ss = opt.type.getSubOptions opt.loc;
in if ss != {} then optionAttrSetToDocList' opt.loc ss else [];
+
subOptionsVisible = docOption.visible && opt.visible or null != "shallow";
in
+
[ docOption ] ++ optionals subOptionsVisible subOptions) (collect isOption options);
/* This function recursively removes all derivation attributes from