From fc9b63f0e67efa32d744bb2f9f8991ca3ad3a665 Mon Sep 17 00:00:00 2001 From: Robin Raymond Date: Mon, 18 Dec 2017 12:26:54 +0100 Subject: [PATCH] add explicit catchAlls #49 --- default.nix | 11 ++++++++++- mail-server/postfix.nix | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 3a13987..5854226 100644 --- a/default.nix +++ b/default.nix @@ -69,6 +69,15 @@ in ''; }; + catchAll = mkOption { + type = with types; listOf (enum cfg.domains); + example = ["example.com" "example2.com"]; + default = []; + description = '' + For which domains should this account act as a catch all? + ''; + }; + sieveScript = mkOption { type = with types; nullOr lines; default = null; @@ -141,7 +150,7 @@ in "abuse@example.com" = "user1@example.com"; }; description = '' - Alias for extraVirtualAliases. + Alias for extraVirtualAliases. Deprecated. ''; default = {}; }; diff --git a/mail-server/postfix.nix b/mail-server/postfix.nix index 0d528fc..bc8ae6c 100644 --- a/mail-server/postfix.nix +++ b/mail-server/postfix.nix @@ -29,6 +29,13 @@ let in map (from: "${from} ${to}") value.aliases) cfg.loginAccounts); + # catchAllPostfix :: [ String ] + catchAllPostfix = lib.flatten (lib.mapAttrsToList + (name: value: + let to = name; + in map (from: "@${from} ${to}") value.catchAll) + cfg.loginAccounts); + # extra_valiases_postfix :: [ String ] # TODO: Remove virtualAliases when deprecated -> removed extra_valiases_postfix = (map @@ -53,7 +60,9 @@ let vaccounts_identity = map accountToIdentity (lib.attrValues cfg.loginAccounts); # valiases_file :: Path - valiases_file = builtins.toFile "valias" (lib.concatStringsSep "\n" all_valiases_postfix); + valiases_file = builtins.toFile "valias" + (lib.concatStringsSep "\n" (all_valiases_postfix ++ + catchAllPostfix)); # vhosts_file :: Path vhosts_file = builtins.toFile "vhosts" (concatStringsSep "\n" cfg.domains);