summary refs log tree commit diff
path: root/lib/options.nix
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2023-05-06 16:50:08 +0200
committerNaïm Favier <n@monade.li>2023-05-06 17:09:10 +0200
commit7cd5b9a6e8c3e4e423d7d10533cc2f1e98a4eca8 (patch)
tree0226734bea186223434e457b60d9be7d4ac84860 /lib/options.nix
parent276f75e5fff8a0ffe15f8c45f5798625fcc20e6e (diff)
downloadnixpkgs-7cd5b9a6e8c3e4e423d7d10533cc2f1e98a4eca8.tar
nixpkgs-7cd5b9a6e8c3e4e423d7d10533cc2f1e98a4eca8.tar.gz
nixpkgs-7cd5b9a6e8c3e4e423d7d10533cc2f1e98a4eca8.tar.bz2
nixpkgs-7cd5b9a6e8c3e4e423d7d10533cc2f1e98a4eca8.tar.lz
nixpkgs-7cd5b9a6e8c3e4e423d7d10533cc2f1e98a4eca8.tar.xz
nixpkgs-7cd5b9a6e8c3e4e423d7d10533cc2f1e98a4eca8.tar.zst
nixpkgs-7cd5b9a6e8c3e4e423d7d10533cc2f1e98a4eca8.zip
lib/options: fix rendering of options with only a defaultText
Some options have their default value set in the `config` instead of
`default`, for example to push `mkDefault`s down an attribute set.
In those cases, it's useful to provide a `defaultText` for informational
purposes.
Diffstat (limited to 'lib/options.nix')
-rw-r--r--lib/options.nix6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/options.nix b/lib/options.nix
index 4780a56fc1c..d71d9421b7b 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -261,7 +261,7 @@ rec {
     concatMap (opt:
       let
         name = showOption opt.loc;
-        docOption = rec {
+        docOption = {
           loc = opt.loc;
           inherit name;
           description = opt.description or null;
@@ -280,9 +280,9 @@ rec {
               renderOptionValue opt.example
             );
         }
-        // optionalAttrs (opt ? default) {
+        // optionalAttrs (opt ? defaultText || opt ? default) {
           default =
-            builtins.addErrorContext "while evaluating the default value of option `${name}`" (
+            builtins.addErrorContext "while evaluating the ${if opt?defaultText then "defaultText" else "default value"} of option `${name}`" (
               renderOptionValue (opt.defaultText or opt.default)
             );
         }