~afontaine/nix

nix/andrew/mail/default.nix -rw-r--r-- 2.7 KiB
1fcb541bAndrew Fontaine Rotate SSH key for nix builds 13 hours ago
                                                                                
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{ config, lib, pkgs, ... }:
with lib;
let
  bw = config.programs.bw.package;
  cfg = config.mail;
in {
  options.mail = {
    enable = mkEnableOption "email syncing";
    enableWork = mkEnableOption "work email accounts";
  };

  config = mkIf cfg.enable {

    programs.bw.enable = true;

    programs.mbsync.enable = true;
    services.mbsync.enable = true;

    programs.msmtp.enable = true;

    accounts.email = {
      maildirBasePath = "${config.xdg.dataHome}/mail";

      accounts = {
        afontaine = {
          realName = "Andrew Fontaine";
          signature = {
            text = ''
              --
              Andrew Fontaine
            '';
            showSignature = "append";
          };
          primary = true;
          address = "andrew@afontaine.ca";
          userName = "andrew@afontaine.ca";
          passwordCommand =
            "${bw}/bin/bw get password webmail.migadu.com 2> /dev/null";

          folders.sent = "Sent";
          folders.trash = "Trash";

          msmtp.enable = true;

          mbsync = {
            enable = true;
            create = "both";
            remove = "both";
            expunge = "both";
            patterns = [ "*" ];
          };

          imap = {
            host = "imap.migadu.com";
            port = 993;
            tls.enable = true;
          };

          smtp = {
            host = "smtp.migadu.com";
            port = 465;
            tls.enable = true;
          };
        };
        gitlab = mkIf cfg.enableWork {
          realName = "Andrew Fontaine";
          signature = {
            text = ''
              --
              Andrew Fontaine
              Senior Frontend Engineer, Release @ GitLab
            '';
            showSignature = "append";
          };
          address = "afontaine@gitlab.com";
          userName = "afontaine@gitlab.com";
          passwordCommand = "${bw}/bin/bw get password gitlab-google 2> /dev/null";

          msmtp.enable = true;

          mbsync = {
            enable = true;
            create = "both";
            expunge = "both";
            remove = "both";
            patterns = [
              "*"
              "![Gmail]*"
              "[Gmail]/Sent Mail"
              "[Gmail]/Trash"
              "[Gmail]/Drafts"
            ];
          };

          imap = {
            host = "imap.gmail.com";
            port = 993;
            tls.enable = true;
          };

          smtp = {
            host = "smtp.gmail.com";
            port = 465;
            tls.enable = true;
          };
        };

      };
    };
    systemd.user.services.mbsync = {
      Service.ExecStartPost =
        "${config.programs.doom-emacs.final}/bin/emacsclient --eval '(mu4e-update-index)'";
    };
  };
}