about summary refs log tree commit diff
path: root/nixpkgs/pkgs/pkgs-lib/formats.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/pkgs-lib/formats.nix')
-rw-r--r--nixpkgs/pkgs/pkgs-lib/formats.nix14
1 files changed, 14 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/pkgs-lib/formats.nix b/nixpkgs/pkgs/pkgs-lib/formats.nix
index 3cbda3a7ebdd..950547c4f001 100644
--- a/nixpkgs/pkgs/pkgs-lib/formats.nix
+++ b/nixpkgs/pkgs/pkgs-lib/formats.nix
@@ -142,6 +142,20 @@ rec {
 
   };
 
+  # As defined by systemd.syntax(7)
+  #
+  # null does not set any value, which allows for RFC42 modules to specify
+  # optional config options.
+  systemd = let
+    mkValueString = lib.generators.mkValueStringDefault {};
+    mkKeyValue = k: v:
+      if v == null then "# ${k} is unset"
+      else "${k} = ${mkValueString v}";
+  in ini {
+    listsAsDuplicateKeys = true;
+    inherit mkKeyValue;
+  };
+
   keyValue = {
     # Represents lists as duplicate keys
     listsAsDuplicateKeys ? false,