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