mailserver: Add option for autoconfig
This commit is contained in:
parent
21e139f313
commit
c3a3e7b99b
|
@ -24,6 +24,10 @@
|
|||
"psycho-power-papagei.de"
|
||||
"sbruder.de"
|
||||
];
|
||||
autoconfig = {
|
||||
enable = true;
|
||||
domain = "sbruder.de";
|
||||
};
|
||||
users = import ./secrets/mail-users.nix;
|
||||
rejectSenders = import ./secrets/mail-reject-senders.nix;
|
||||
};
|
||||
|
|
|
@ -27,6 +27,24 @@ in
|
|||
description = "Domains to serve";
|
||||
example = [ "example.com" "example.org" ];
|
||||
};
|
||||
autoconfig = {
|
||||
enable = mkEnableOption "autoconfiguration of compatible clients. Requires autoconfig.<domain> to exist for all specified domains";
|
||||
domain = mkOption {
|
||||
type = str;
|
||||
description = "Domain of the mail system.";
|
||||
example = "example.com";
|
||||
};
|
||||
displayName = mkOption {
|
||||
type = str;
|
||||
description = "Name of the mail system.";
|
||||
default = cfg.autoconfig.domain;
|
||||
};
|
||||
displayShortName = mkOption {
|
||||
type = str;
|
||||
description = "Short name of the mail system.";
|
||||
default = cfg.autoconfig.displayName;
|
||||
};
|
||||
};
|
||||
users = mkOption {
|
||||
type = listOf (submodule {
|
||||
options = {
|
||||
|
@ -541,5 +559,41 @@ in
|
|||
};
|
||||
|
||||
users.users.postfix.extraGroups = lib.mkIf cfg.dkim.enable (lib.singleton config.users.users.opendkim.group);
|
||||
|
||||
# Autoconfig
|
||||
services.nginx = lib.mkIf cfg.autoconfig.enable {
|
||||
enable = true;
|
||||
virtualHosts = lib.listToAttrs (map
|
||||
(domain: lib.nameValuePair "autoconfig.${domain}" {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
|
||||
locations."=/mail/config-v1.1.xml".alias = pkgs.writeText "config-v1.1.xml" ''
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<clientConfig version="1.1">
|
||||
<emailProvider id="mysystems.tld">
|
||||
<domain>${lib.escapeXML cfg.autoconfig.domain}</domain>
|
||||
<displayName>${lib.escapeXML cfg.autoconfig.displayName}</displayName>
|
||||
<displayShortName>${lib.escapeXML cfg.autoconfig.displayShortName}</displayShortName>
|
||||
<incomingServer type="imap">
|
||||
<hostname>${lib.escapeXML cfg.fqdn}</hostname>
|
||||
<port>993</port>
|
||||
<socketType>SSL</socketType>
|
||||
<authentication>password-cleartext</authentication>
|
||||
<username>%EMAILADDRESS%</username>
|
||||
</incomingServer>
|
||||
<outgoingServer type="smtp">
|
||||
<hostname>${lib.escapeXML cfg.fqdn}</hostname>
|
||||
<port>465</port>
|
||||
<socketType>SSL</socketType>
|
||||
<authentication>password-cleartext</authentication>
|
||||
<username>%EMAILADDRESS%</username>
|
||||
</outgoingServer>
|
||||
</emailProvider>
|
||||
</clientConfig>
|
||||
'';
|
||||
})
|
||||
cfg.domains);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue