lib/options: defaultNullOpts support non-string defaults

This commit is contained in:
Matt Sturgeon 2024-05-28 18:49:16 +01:00
parent deafcf44de
commit daa6b0f5cf
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -57,7 +57,20 @@ rec {
defaultNullOpts = rec {
# Description helpers
mkDefaultDesc = defaultValue: "Plugin default: `${toString defaultValue}`";
mkDefaultDesc =
defaultValue:
let
default =
# Assume a string default is already formatted as intended,
# historically strings were the only type accepted here.
# TODO consider deprecating this behavior so we can properly quote strings
if isString defaultValue then
defaultValue
else
generators.toPretty { multiline = false; } defaultValue;
in
"Plugin default: `${default}`";
mkDesc =
default: desc:
let