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:
parent
9753b2863b
commit
951a020ed4
1 changed files with 26 additions and 9 deletions
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue