Merge pull request #244819 from ncfavier/toKeyValue-indent

lib/generators/toKeyValue: add `indent` parameter
This commit is contained in:
Naïm Favier 2023-07-25 18:57:04 +02:00 committed by GitHub
commit b97ac82725
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,9 +81,10 @@ rec {
*/
toKeyValue = {
mkKeyValue ? mkKeyValueDefault {} "=",
listsAsDuplicateKeys ? false
listsAsDuplicateKeys ? false,
indent ? ""
}:
let mkLine = k: v: mkKeyValue k v + "\n";
let mkLine = k: v: indent + mkKeyValue k v + "\n";
mkLines = if listsAsDuplicateKeys
then k: v: map (mkLine k) (if lib.isList v then v else [v])
else k: v: [ (mkLine k v) ];