mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-30 16:10:36 +00:00
lib/generators/toINI: partially apply functions
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user