diff --git a/pkgs/pkgs-lib/formats/java-properties/default.nix b/pkgs/pkgs-lib/formats/java-properties/default.nix index e4f42a61f5c..b63b96d3276 100644 --- a/pkgs/pkgs-lib/formats/java-properties/default.nix +++ b/pkgs/pkgs-lib/formats/java-properties/default.nix @@ -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" ''; }; } diff --git a/pkgs/pkgs-lib/tests/formats.nix b/pkgs/pkgs-lib/tests/formats.nix index 71b4a3946a3..1efe9d8686b 100644 --- a/pkgs/pkgs-lib/tests/formats.nix +++ b/pkgs/pkgs-lib/tests/formats.nix @@ -179,6 +179,8 @@ in runBuildTests { "الجبر" = "أكثر من مجرد أرقام"; }; expected = '' + # Generated with Nix + 1 = 2 foo = bar \u00fctf\ 8 = d\u00fbh