summaryrefslogtreecommitdiffstats
path: root/pkgs/pkgs-lib
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2022-09-01 14:43:59 +0200
committerRaito Bezarius <masterancpp@gmail.com>2023-12-09 01:50:23 +0100
commitad586e6bebef46d3a2e61751b5e028dd261556b3 (patch)
tree79c6700753a4328cff3a43a7b7f219aabbdc27c1 /pkgs/pkgs-lib
parentf9a1ba6987b55de1ab9836af799028ade39168e5 (diff)
formats.systemd: init INI-style systemd config file format
Diffstat (limited to 'pkgs/pkgs-lib')
-rw-r--r--pkgs/pkgs-lib/formats.nix14
1 files changed, 14 insertions, 0 deletions
diff --git a/pkgs/pkgs-lib/formats.nix b/pkgs/pkgs-lib/formats.nix
index 3cbda3a7ebdd..950547c4f001 100644
--- a/pkgs/pkgs-lib/formats.nix
+++ b/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,