From 01efd5876b0eb83ffe478e20ec57ffb45e3e1ba8 Mon Sep 17 00:00:00 2001 From: Eman Resu Date: Fri, 9 Oct 2026 16:12:04 -0400 Subject: [PATCH] lib/generators/toINI: partially apply functions --- lib/generators.nix | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/generators.nix b/lib/generators.nix index d7097416fa82..fabb439946c8 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -247,26 +247,31 @@ rec { ::: */ toINI = - { - mkSectionName ? (name: escape [ "[" "]" ] name), - mkKeyValue ? mkKeyValueDefault { } "=", - listsAsDuplicateKeys ? false, - }: - attrsOfAttrs: let # map function to string for each key val mapAttrsToStringsSep = sep: mapFn: attrs: concatStringsSep sep (mapAttrsToList mapFn attrs); + in + { + mkSectionName ? escape [ + "[" + "]" + ], + mkKeyValue ? mkKeyValueDefault { } "=", + listsAsDuplicateKeys ? false, + }: + let + toKeyValue' = toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; }; mkSection = sectName: sectValues: '' [${mkSectionName sectName}] '' - + toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } sectValues; + + toKeyValue' sectValues; in # map input to ini sections - mapAttrsToStringsSep "\n" mkSection attrsOfAttrs; + mapAttrsToStringsSep "\n" mkSection; /** Generate an INI-style config file from an attrset