]> Git — Sourcephile - sourcephile-nix.git/blob - install/logical/friot/dovecot/autoconfig.nix
update openldap, dovecot, postfix.
[sourcephile-nix.git] / install / logical / friot / dovecot / autoconfig.nix
1 {pkgs, lib, config, ...}:
2 let inherit (builtins) attrNames;
3 inherit (config.services) dovecot2;
4 in
5 {
6 config = {
7 services.nginx = {
8 virtualHosts."autoconfig" =
9 let servers = lib.concatMapStringsSep " "
10 (dom: "autoconfig.${dom}")
11 (attrNames dovecot2.domains);
12 in
13 {
14 serverName = "autoconfig.${config.networking.domain}";
15 #addSSL = true;
16 extraConfig = ''
17 access_log off;
18 log_not_found off;
19 '';
20 root = pkgs.writeTextFile {
21 name = "autoconfig";
22 destination = "/mail/config-v1.1.xml";
23 text = ''
24 <?xml version="1.0"?>
25 <clientConfig version="1.1">
26 <emailProvider id="%EMAILDOMAIN%">
27 <!-- <displayName></displayName> -->
28 <!-- <displayShortName></displayShortName> -->
29 <domain>%EMAILDOMAIN%</domain>
30 <incomingServer type="imap">
31 <hostname>mail.%EMAILDOMAIN%</hostname>
32 <port>993</port>
33 <socketType>SSL</socketType>
34 <username>%EMAILADDRESS%</username>
35 <authentication>password-cleartext</authentication>
36 </incomingServer>
37 <incomingServer type="pop3">
38 <hostname>mail.%EMAILDOMAIN%</hostname>
39 <port>995</port>
40 <socketType>SSL</socketType>
41 <username>%EMAILADDRESS%</username>
42 <authentication>password-cleartext</authentication>
43 <pop3>
44 <leaveMessagesOnServer>false</leaveMessagesOnServer>
45 <downloadOnBiff>true</downloadOnBiff>
46 </pop3>
47 </incomingServer>
48 <outgoingServer type="smtp">
49 <hostname>mail.%EMAILDOMAIN%</hostname>
50 <port>465</port>
51 <socketType>SSL</socketType> <!-- see above -->
52 <username>%EMAILADDRESS%</username> <!-- if smtp-auth -->
53 <authentication>password-cleartext</authentication>
54 <!-- <restriction>client-IP-address</restriction> -->
55 <addThisServer>true</addThisServer>
56 <useGlobalPreferredServer>false</useGlobalPreferredServer>
57 </outgoingServer>
58 </emailProvider>
59 <!-- <clientConfigUpdate url="https://www.example.com/config/mozilla.xml" /> -->
60 </clientConfig>
61 '';
62 };
63 };
64 };
65 };
66 }