formats.javaProperties: Add comment

Changed files
+11 -4
pkgs
pkgs-lib
formats
java-properties
tests
+9 -4
pkgs/pkgs-lib/formats/java-properties/default.nix
···
{ lib, pkgs }:
{
-
javaProperties = {}: {
+
javaProperties = { comment ? "Generated with Nix" }: {
type = lib.types.attrsOf lib.types.str;
generate = name: value:
···
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"
'';
};
}
+2
pkgs/pkgs-lib/tests/formats.nix
···
"الجبر" = "أكثر من مجرد أرقام";
};
expected = ''
+
# Generated with Nix
+
1 = 2
foo = bar
\u00fctf\ 8 = d\u00fbh