formats.javaProperties: Add comment

This commit is contained in:
Robert Hensing 2022-03-28 09:23:25 +02:00
parent 4f8e44394c
commit 9a0739cbe2
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ lib, pkgs }:
{
javaProperties = {}: {
javaProperties = { comment ? "Generated with Nix" }: {
type = lib.types.attrsOf lib.types.str;
generate = name: value:
@ -76,10 +76,15 @@
inputEncoding = "UTF-8";
inherit comment;
} ''
jq -r --arg hash '#' "$jqCode" "$valuePath" \
| iconv --from-code "$inputEncoding" --to-code JAVA \
> "$out"
(
echo "$comment" | while read -r ln; do echo "# $ln"; done
echo
jq -r --arg hash '#' "$jqCode" "$valuePath" \
| iconv --from-code "$inputEncoding" --to-code JAVA \
) > "$out"
'';
};
}

View File

@ -179,6 +179,8 @@ in runBuildTests {
"الجبر" = "أكثر من مجرد أرقام";
};
expected = ''
# Generated with Nix
1 = 2
foo = bar
\u00fctf\ 8 = d\u00fbh