summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--module.nix20
1 files changed, 11 insertions, 9 deletions
diff --git a/module.nix b/module.nix
index 85e033d..23f62e4 100644
--- a/module.nix
+++ b/module.nix
@@ -6,14 +6,14 @@ in {
options.services.smtp-forward = {
enable = lib.mkEnableOption "the smtp-forward service";
mapping = lib.mkOption {
- type = lib.types.str;
+ type = lib.types.strMatching "([^:]+:[^:]+@[^,]+)(,[^:]+:[^:]+@[^,]+)*";
default = "prefix1:addres@host,prefix2:address@host";
description = "-m maps prefixes to email addresses";
};
listen = lib.mkOption {
type = lib.types.str;
default = ":25";
- description = "Adress to listen on";
+ description = "-l sets the address to listen on";
};
hostname = lib.mkOption {
type = lib.types.str;
@@ -21,14 +21,14 @@ in {
description = "-h sets the server hostname";
};
key = lib.mkOption {
- type = lib.types.str;
- default = "setme";
- description = "-k sets the TLS key";
+ type = lib.types.path;
+ default = null;
+ description = "-k /path/to/file sets the TLS key file";
};
cert = lib.mkOption {
- type = lib.types.str;
- default = "setme";
- description = "-c sets the TLS key";
+ type = lib.types.path;
+ default = null;
+ description = "-c /path/to/file" sets the TLS certificate file";
};
};
config = lib.mkIf config.services.smtp-forward.enable {
@@ -37,7 +37,9 @@ in {
path = [ package ];
wantedBy = [ "default.target" ];
script = ''
- ${package}/bin/smtp-forward -l ${cfg.listen} -m ${cfg.mapping} -h ${cfg.hostname} -k ${cfg.key} -c ${cfg.cert}
+ ${package}/bin/smtp-forward -l ${cfg.listen} -m ${cfg.mapping} -h ${cfg.hostname} \
+ ${lib.optionalString (cfg.key != null) "-k ${cfg.key}"} \
+ ${lib.optionalString (cfg.cert != null) "-c ${cfg.cert}"}
'';
serviceConfig = {
User = "smtp-forward";