From 9a0739cbe2b3b56dbc923a36f4e204afba917641 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 28 Mar 2022 09:23:25 +0200 Subject: [PATCH] formats.javaProperties: Add comment --- pkgs/pkgs-lib/formats/java-properties/default.nix | 13 +++++++++---- pkgs/pkgs-lib/tests/formats.nix | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/pkgs-lib/formats/java-properties/default.nix b/pkgs/pkgs-lib/formats/java-properties/default.nix index e4f42a61f5c8..b63b96d32769 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 71b4a3946a34..1efe9d8686b1 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