mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
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.
This commit is contained in:
parent
276f75e5ff
commit
7cd5b9a6e8
@ -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)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user