From daa6b0f5cff90397b8ebd9ab5f5976b06b95c5e6 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 28 May 2024 18:49:16 +0100 Subject: [PATCH] lib/options: defaultNullOpts support non-string defaults --- lib/options.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/options.nix b/lib/options.nix index 801100ee..34b6d155 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -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