summaryrefslogtreecommitdiff
path: root/lib/email.nix
blob: c6401206bb1fa71201175da7ba417344fecdde8a (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
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
{ pkgs, lib, config, ... }:

let
  inherit (import ./const.nix) homedir gpgid;
  common = {
    alot.sendMailCommand = "${homedir}/bin/sendmail";
    imap = {
      host = "bensima.com";
      port = 993;
    };
    smtp = {
      host = "bensima.com";
      port = 587;
      tls = {
        enable = true;
        useStartTls = true;
      };
    };
    gpg = {
      key = gpgid;
      signByDefault = true;
      encryptByDefault = false;
    };
    mbsync = {
      enable = true;
      create = "both";
      expunge = "both";
      remove = "both";
      extraConfig.channel = {
        # MaxMessages = 1000;
        Sync = ["All" "Flags"];
      };
    };
    passwordCommand = "${pkgs.pass}/bin/pass ben@bensima.com";
    msmtp.enable = true;
    mu.enable = true;
  };
in
{
  accounts = {
    email = {
      maildirBasePath = "${homedir}/Mail";
      accounts = {
        "ben@bensima.com" = common // {
          primary = true;
          realName = "Ben Sima";
          address = "ben@bensima.com";
          userName = "ben@bensima.com";
        };

        "dev@bensima.com" = common // {
          realName = "Ben Sima";
          address = "dev@bensima.com";
          userName = "dev@bensima.com";
          mbsync.enable = false;
        };
      };
    };
  };

  programs = {
    notmuch = {
      enable = false;
      new.tags = [ "new" ];
      maildir.synchronizeFlags = true;
      hooks = {
        postNew = ''
          ${pkgs.afew}/bin/afew --tag --new
          ${pkgs.afew}/bin/afew --tag tag:inbox
          ${pkgs.afew}/bin/afew --move-mail
        '';
      };
      extraConfig = {
        search = {
          exclude_tags = "deleted;spam;";
        };
      };
    };

    afew = {
      enable = false;
      extraConfig = builtins.readFile ./afew.ini;
    };

    alot = {
      enable = false;
      extraConfig = ''
        theme = solarized_light
      '';
    };

    mbsync.enable = true;

    msmtp = {
      enable = true;
    };

    mu.enable = true;
  };

  services = {
    mbsync.enable = false; # just update manually in emacs
    mbsync.frequency = "hourly";
    mbsync.postExec = "${config.programs.mu.package}/bin/mu index";
  };
}