mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03: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
1 changed files with 3 additions and 3 deletions
|
@ -261,7 +261,7 @@ rec {
|
||||||
concatMap (opt:
|
concatMap (opt:
|
||||||
let
|
let
|
||||||
name = showOption opt.loc;
|
name = showOption opt.loc;
|
||||||
docOption = rec {
|
docOption = {
|
||||||
loc = opt.loc;
|
loc = opt.loc;
|
||||||
inherit name;
|
inherit name;
|
||||||
description = opt.description or null;
|
description = opt.description or null;
|
||||||
|
@ -280,9 +280,9 @@ rec {
|
||||||
renderOptionValue opt.example
|
renderOptionValue opt.example
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// optionalAttrs (opt ? default) {
|
// optionalAttrs (opt ? defaultText || opt ? default) {
|
||||||
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)
|
renderOptionValue (opt.defaultText or opt.default)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue