This commit is contained in:
Charlotte Van Petegem 2020-10-17 16:32:49 +02:00
parent a38d907959
commit 6cc5211c9c
No known key found for this signature in database
GPG key ID: 019E764B7184435A

View file

@ -63,20 +63,23 @@ let
}; };
}; };
}; };
repeat = count: char: lib.strings.concatStrings (builtins.genList (_: char) count); toRecursiveINI = with lib.strings; with lib.attrsets; with lib.generators; with lib.lists; let
mkHeader = depth: name: lib.strings.concatStrings [ (repeat depth "[") name (repeat depth "]") ]; repeat = count: char: concatStrings (genList (_: char) count);
simpleAttrs = lib.attrsets.filterAttrs (n: v: !(builtins.isAttrs v)); mkHeader = depth: name: concatStrings [ (repeat depth "[") (escape [ "[" ] name) (repeat depth "]") ];
complexAttrs = lib.attrsets.filterAttrs (n: v: builtins.isAttrs v); simpleAttrs = filterAttrs (n: v: !(isAttrs v));
toRecursiveINIBase = depth: data: (builtins.concatStringsSep "\n" ( complexAttrs = filterAttrs (n: v: isAttrs v);
lib.attrsets.mapAttrsToList removeEmpty = filter (v: v != "");
(name: values: builtins.concatStringsSep "\n" (builtins.filter (v: v != "") [ toRecursiveINIBase = depth: data: (concatStringsSep "\n" (
mapAttrsToList
(name: values: concatStringsSep "\n" (removeEmpty [
(mkHeader depth name) (mkHeader depth name)
(lib.generators.toKeyValue { } (simpleAttrs values)) (toKeyValue { } (simpleAttrs values))
(toRecursiveINIBase (depth + 1) (complexAttrs values)) (toRecursiveINIBase (depth + 1) (complexAttrs values))
])) ]))
data data
)); ));
toRecursiveINI = toRecursiveINIBase 1; in
toRecursiveINIBase 1;
in in
{ {
custom.zfs.homeLinks = [ custom.zfs.homeLinks = [