0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50: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
inherit (lib)
mkOption
types
;
cfg = config.services.postfix;
user = cfg.user;
@ -47,7 +51,11 @@ let
);
mkEntry = name: value: "${escape name} =${mkVal value}";
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 =
{
@ -564,16 +572,25 @@ in
};
config = lib.mkOption {
type =
with lib.types;
attrsOf (oneOf [
bool
int
str
(listOf str)
]);
type = lib.types.submodule {
freeformType =
with types;
attrsOf (
nullOr (oneOf [
bool
int
str
(listOf str)
])
);
options = {
};
};
description = ''
The main.cf configuration file as key value set.
Null values will not be rendered.
'';
example = {
mail_owner = "postfix";