1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 23:19:47 +01:00

WIP: formatting

This commit is contained in:
Constantin Gahr 2023-10-29 09:59:09 +01:00
parent a07429259f
commit 42b48bca0f
2 changed files with 18 additions and 21 deletions

View file

@ -1,7 +1,7 @@
{ lib }:
{
toKDL = {}:
toKDL = { }:
let
inherit (lib) mapAttrsToList;
inherit (builtins) typeOf replaceStrings elem;
@ -19,20 +19,20 @@
# OneOf [Int Float String Bool Null] -> String
convertLiteralValueToString = isName: element:
lib.throwIfNot (isLiteral element)
"Cannot convert value of type ${typeOf element} to KDL literal."
(if typeOf element == "null" then
"null"
else if element == false then
"false"
else if element == true then
"true"
else if typeOf element == "string" then
if isName then
sanitizeName element
else
''"'' + sanitizeValue element + ''"''
"Cannot convert value of type ${typeOf element} to KDL literal."
(if typeOf element == "null" then
"null"
else if element == false then
"false"
else if element == true then
"true"
else if typeOf element == "string" then
if isName then
sanitizeName element
else
toString element);
''"'' + sanitizeValue element + ''"''
else
toString element);
convertListElement = elem:
if builtins.isAttrs elem then
@ -49,8 +49,7 @@
emptyRet = [ (sanitizeName name) ];
prefix = [ (sanitizeName name + " {") ];
suffix = [ "}" ];
in
if builtins.isList value then
in if builtins.isList value then
if value == [ ] then
emptyRet
else
@ -64,6 +63,5 @@
sanitizeName name + " " + (convertLiteralValueToString false value);
convertSetToKDL = set: flatten (mapAttrsToList convertSetElement set);
in
attrs: lib.concatStringsSep "\n" (flatten (convertSetToKDL attrs));
in attrs: lib.concatStringsSep "\n" (flatten (convertSetToKDL attrs));
}

View file

@ -36,9 +36,8 @@
}
"pane"
{
"pane size=2 borderless=true" = [
''plugin location="zellij:status-bar"''
];
"pane size=2 borderless=true" =
[ ''plugin location="zellij:status-bar"'' ];
}
];
};