about summary refs log tree commit diff
path: root/pkgs/pkgs-lib/formats/java-properties/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/pkgs-lib/formats/java-properties/default.nix')
-rw-r--r--pkgs/pkgs-lib/formats/java-properties/default.nix13
1 files changed, 9 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"
       '';
   };
 }