mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +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
|
nameValuePair
|
||||||
optionalString
|
optionalString
|
||||||
types
|
types
|
||||||
|
isBool
|
||||||
|
boolToString
|
||||||
;
|
;
|
||||||
inherit (types) listOf package;
|
inherit (types) listOf package;
|
||||||
|
|
||||||
|
@ -26,6 +28,15 @@ let
|
||||||
settingsFormat = pkgs.formats.keyValue { listsAsDuplicateKeys = true; };
|
settingsFormat = pkgs.formats.keyValue { listsAsDuplicateKeys = true; };
|
||||||
inherit (settingsFormat) generate type;
|
inherit (settingsFormat) generate type;
|
||||||
|
|
||||||
|
recursiveToString =
|
||||||
|
value:
|
||||||
|
if isList value then
|
||||||
|
map recursiveToString value
|
||||||
|
else if isBool value then
|
||||||
|
boolToString value
|
||||||
|
else
|
||||||
|
toString value;
|
||||||
|
|
||||||
initScript =
|
initScript =
|
||||||
{
|
{
|
||||||
program,
|
program,
|
||||||
|
@ -97,12 +108,7 @@ in
|
||||||
environment = {
|
environment = {
|
||||||
systemPackages = [ cfg.package ] ++ cfg.extraPackages;
|
systemPackages = [ cfg.package ] ++ cfg.extraPackages;
|
||||||
etc."bat/config".source = generate "bat-config" (
|
etc."bat/config".source = generate "bat-config" (
|
||||||
mapAttrs' (
|
mapAttrs' (name: value: nameValuePair ("--" + name) (recursiveToString value)) cfg.settings
|
||||||
name: value:
|
|
||||||
nameValuePair ("--" + name) (
|
|
||||||
if (isList value) then map (str: "\"${str}\"") value else "\"${value}\""
|
|
||||||
)
|
|
||||||
) cfg.settings
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue