nixos/bat: fix settings type handling

This commit is contained in:
Tanya 2025-03-24 01:13:32 +05:30 committed by Masum Reza
parent 3471e77433
commit 5c72fd6842

View file

@ -18,6 +18,8 @@ let
nameValuePair
optionalString
types
isBool
boolToString
;
inherit (types) listOf package;
@ -26,6 +28,15 @@ let
settingsFormat = pkgs.formats.keyValue { listsAsDuplicateKeys = true; };
inherit (settingsFormat) generate type;
recursiveToString =
value:
if isList value then
map recursiveToString value
else if isBool value then
boolToString value
else
toString value;
initScript =
{
program,
@ -97,12 +108,7 @@ in
environment = {
systemPackages = [ cfg.package ] ++ cfg.extraPackages;
etc."bat/config".source = generate "bat-config" (
mapAttrs' (
name: value:
nameValuePair ("--" + name) (
if (isList value) then map (str: "\"${str}\"") value else "\"${value}\""
)
) cfg.settings
mapAttrs' (name: value: nameValuePair ("--" + name) (recursiveToString value)) cfg.settings
);
};