diff --git a/nixos/modules/services/mail/postfix.nix b/nixos/modules/services/mail/postfix.nix index 34c236dcd2a6..37bd3877747e 100644 --- a/nixos/modules/services/mail/postfix.nix +++ b/nixos/modules/services/mail/postfix.nix @@ -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";