aboutsummaryrefslogtreecommitdiff
path: root/users/tdback/modules/email/default.nix
blob: 34eef65e9755ec34fb1f36471b46e685c0658c7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{ lib, pkgs, ... }:
{
  accounts.email = {
    maildirBasePath = "mail";
    accounts.fastmail = {
      primary = true;
      address = "tyler@tdback.net";
      userName = "tyler@tdback.net";
      realName = "Tyler Dunneback";
      passwordCommand = "${lib.getExe pkgs.age} -d -i ~/.ssh/mail ~/.mail.age";

      folders = {
        inbox = "Inbox";
        drafts = "Drafts";
        sent = "Sent";
        trash = "Trash";
      };

      imap = {
        host = "imap.fastmail.com";
        port = 993;
        tls = {
          enable = true;
          certificatesFile = "/etc/ssl/certs/ca-certificates.crt";
        };
      };

      smtp = {
        host = "smtp.fastmail.com";
        port = 465;
        tls = {
          enable = true;
          useStartTls = false;
          certificatesFile = "/etc/ssl/certs/ca-certificates.crt";
        };
      };

      mbsync = {
        enable = true;
        create = "both";
        expunge = "none";
        subFolders = "Verbatim";
        patterns = [ "*" ];
      };

      msmtp = {
        enable = true;
        extraConfig = {
          logfile = "~/.cache/msmtp/msmtp.log";
        };
      };

      neomutt = {
        enable = true;
        sendMailCommand = "msmtp";
        mailboxType = "maildir";
        extraMailboxes = [
          "Drafts"
          "Sent"
          "Trash"
          "Archive"
        ];
      };
    };
  };

  programs = {
    mbsync.enable = true;
    msmtp.enable = true;
  };

  services.mbsync = {
    enable = true;
    package = pkgs.isync;
    frequency = "*:0/5";
  };
}