summary refs log tree commit diff
path: root/lib/options.nix
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2021-10-28 18:04:49 +0200
committerRobert Hensing <robert@roberthensing.nl>2021-11-01 09:34:07 +0100
commit64dfd983df61d9c427ac01d0d25b8d2f26b4c3d5 (patch)
tree38c14b3be02575e906052629d7ea0af7dc0f9c3f /lib/options.nix
parent27644a82a99b4855e40dfd6c09d7288664217662 (diff)
downloadnixpkgs-64dfd983df61d9c427ac01d0d25b8d2f26b4c3d5.tar
nixpkgs-64dfd983df61d9c427ac01d0d25b8d2f26b4c3d5.tar.gz
nixpkgs-64dfd983df61d9c427ac01d0d25b8d2f26b4c3d5.tar.bz2
nixpkgs-64dfd983df61d9c427ac01d0d25b8d2f26b4c3d5.tar.lz
nixpkgs-64dfd983df61d9c427ac01d0d25b8d2f26b4c3d5.tar.xz
nixpkgs-64dfd983df61d9c427ac01d0d25b8d2f26b4c3d5.tar.zst
nixpkgs-64dfd983df61d9c427ac01d0d25b8d2f26b4c3d5.zip
modules: Add visible = "shallow" to hide only sub-options
Diffstat (limited to 'lib/options.nix')
-rw-r--r--lib/options.nix10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/options.nix b/lib/options.nix
index b3164181312..5d52f065af0 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -74,7 +74,7 @@ rec {
     apply ? null,
     # Whether the option is for NixOS developers only.
     internal ? null,
-    # Whether the option shows up in the manual.
+    # 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,
@@ -180,7 +180,10 @@ rec {
           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;
+          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;
         }
@@ -192,8 +195,9 @@ rec {
         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 docOption.visible subOptions) (collect isOption options);
+        [ docOption ] ++ optionals subOptionsVisible subOptions) (collect isOption options);
 
 
   /* This function recursively removes all derivation attributes from