0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 06:00:33 +03:00

nixos/postfix: make config freeform and drop null values

This is the basis for defining common options on
`services.postfix.config` while not rendering them, when they're set to
`null`.
This commit is contained in:
Martin Weinelt 2025-06-03 02:08:29 +02:00
parent 9753b2863b
commit 951a020ed4
No known key found for this signature in database
GPG key ID: 87C1E9888F856759

View file

@ -5,6 +5,10 @@
... ...
}: }:
let let
inherit (lib)
mkOption
types
;
cfg = config.services.postfix; cfg = config.services.postfix;
user = cfg.user; user = cfg.user;
@ -47,7 +51,11 @@ let
); );
mkEntry = name: value: "${escape name} =${mkVal value}"; mkEntry = name: value: "${escape name} =${mkVal value}";
in in
lib.concatStringsSep "\n" (lib.mapAttrsToList mkEntry cfg.config) + "\n" + cfg.extraConfig; lib.concatStringsSep "\n" (
lib.mapAttrsToList mkEntry (lib.filterAttrsRecursive (_: value: value != null) cfg.config)
)
+ "\n"
+ cfg.extraConfig;
masterCfOptions = masterCfOptions =
{ {
@ -564,16 +572,25 @@ in
}; };
config = lib.mkOption { config = lib.mkOption {
type = type = lib.types.submodule {
with lib.types; freeformType =
attrsOf (oneOf [ with types;
bool attrsOf (
int nullOr (oneOf [
str bool
(listOf str) int
]); str
(listOf str)
])
);
options = {
};
};
description = '' description = ''
The main.cf configuration file as key value set. The main.cf configuration file as key value set.
Null values will not be rendered.
''; '';
example = { example = {
mail_owner = "postfix"; mail_owner = "postfix";