mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
nixos/bat: fix settings type handling
This commit is contained in:
parent
3471e77433
commit
5c72fd6842
1 changed files with 12 additions and 6 deletions
|
@ -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
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue