diff --git a/default.nix b/default.nix index d5513f6..4fe7778 100644 --- a/default.nix +++ b/default.nix @@ -61,8 +61,9 @@ in }; aliases = mkOption { - type = types.listOf types.str; + type = with types; listOf types.str; example = ["abuse@example.com" "postmaster@example.com"]; + default = []; description = '' A list of aliases of this login account. ''; diff --git a/mail-server/postfix.nix b/mail-server/postfix.nix index a2ec9ef..22d445e 100644 --- a/mail-server/postfix.nix +++ b/mail-server/postfix.nix @@ -23,12 +23,20 @@ let cfg = config.mailserver; # valiases_postfix :: [ String ] - valiases_postfix = map + valiases_postfix = lib.flatten (lib.mapAttrsToList + (name: value: + let to = name; + in map (from: "${from} ${to}") value.aliases) + cfg.loginAccounts); + + # extra_valiases_postfix :: [ String ] + extra_valiases_postfix = map (from: let to = cfg.virtualAliases.${from}; in "${from} ${to}") (builtins.attrNames cfg.virtualAliases); + # accountToIdentity :: User -> String accountToIdentity = account: "${account.name} ${account.name}"; @@ -36,7 +44,7 @@ let vaccounts_identity = map accountToIdentity (lib.attrValues cfg.loginAccounts); # valiases_file :: Path - valiases_file = builtins.toFile "valias" (lib.concatStringsSep "\n" valiases_postfix); + valiases_file = builtins.toFile "valias" (lib.concatStringsSep "\n" extra_valiases_postfix); # vhosts_file :: Path vhosts_file = builtins.toFile "vhosts" (concatStringsSep "\n" cfg.domains); @@ -47,7 +55,8 @@ let # for details on how this file looks. By using the same file as valiases, # every alias is owned (uniquely) by its user. We have to add the users own # address though - vaccounts_file = builtins.toFile "vaccounts" (lib.concatStringsSep "\n" (vaccounts_identity ++ valiases_postfix)); + vaccounts_file = builtins.toFile "vaccounts" (lib.concatStringsSep "\n" + (vaccounts_identity ++ extra_valiases_postfix)); submissionHeaderCleanupRules = pkgs.writeText "submission_header_cleanup_rules" '' # Removes sensitive headers from mails handed in via the submission port.