aboutsummaryrefslogtreecommitdiff
path: root/modules/email/aerc.home.nix
blob: 7dcd99e120984b8666e5b0be4150ed743694fd56 (plain) (blame)
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
{ config, ... }:
# Create private.nix with work.email, work.name
# Setup with `notmuch setup`
# Authenticate with `take ~/mail/account.gmail/ && gmi init <email>`
let
  private = import ./private.nix;
  theme = import ./aerc.theme.nix;
  maildir = "${config.home.homeDirectory}/mail";
  work-maildir = "${maildir}/account.gmail";
in {
  imports = [ ./mailbox-sync.module.nix ];

  services.mailbox-sync = {
    enable = true;
    name = "work";
    maildir = work-maildir;
    sync.frequency = "*:0/5";
    notify.enable = true;
  };

  programs.notmuch = {
    enable = true;
    new = {
      tags = ["new"];
      ignore = ["/.*[.](json|lock|bak)$/"];
    };
    extraConfig = {
      database = {
        path = maildir;
      };
      user = {
        name = private.work.name;
        primary_email = private.work.email;
      };
      search = {
        exclude_tags = "ignored";
      };
    };
  };

  programs.aerc = {
    enable = true;

    extraAccounts.Work = {
      from              = "${private.work.name} <${private.work.email}>";
      source            = "notmuch://${maildir}";
      outgoing          = "gmi send -t -C ${work-maildir}";
      query-map         = "${./query-map.conf}";
      folders-sort      = "Inbox,Unread,Important,_sent,_spam";
      default           = "INBOX";
      copy-to           = "Sent";
      postpone          = "[Gmail]/Drafts";
      cache-headers     = true;
    };

    extraConfig = builtins.readFile ./aerc.conf;
    extraBinds = builtins.readFile ./aerc-binds.conf;

    stylesets.default = theme;
  };
}