about summary refs log tree commit diff
path: root/pkgs/pkgs-lib
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-03-28 09:23:25 +0200
committerRobert Hensing <robert@roberthensing.nl>2022-04-01 15:19:45 +0200
commit9a0739cbe2b3b56dbc923a36f4e204afba917641 (patch)
tree5709a1466e206e0faddbe2844855c658d7cd77c3 /pkgs/pkgs-lib
parent4f8e44394cb5afdef302618d3b2a75ad4291c71f (diff)
downloadnixlib-9a0739cbe2b3b56dbc923a36f4e204afba917641.tar
nixlib-9a0739cbe2b3b56dbc923a36f4e204afba917641.tar.gz
nixlib-9a0739cbe2b3b56dbc923a36f4e204afba917641.tar.bz2
nixlib-9a0739cbe2b3b56dbc923a36f4e204afba917641.tar.lz
nixlib-9a0739cbe2b3b56dbc923a36f4e204afba917641.tar.xz
nixlib-9a0739cbe2b3b56dbc923a36f4e204afba917641.tar.zst
nixlib-9a0739cbe2b3b56dbc923a36f4e204afba917641.zip
formats.javaProperties: Add comment
Diffstat (limited to 'pkgs/pkgs-lib')
-rw-r--r--pkgs/pkgs-lib/formats/java-properties/default.nix13
-rw-r--r--pkgs/pkgs-lib/tests/formats.nix2
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