aboutsummaryrefslogtreecommitdiffstats
path: root/modules/communication/neomutt/neomutt.nix
blob: 6cabf988914e9368228afb0d89ef0c3d0f36a555 (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
# neomutt - Terminal email client
{
  config,
  lib,
  pkgs,
  ...
}:
let
  neomuttDesktopItem = pkgs.makeDesktopItem {
    name = "neomutt";
    desktopName = "NeoMutt";
    exec = "${lib.getExe config.terminal.kitty.package} -e ${lib.getExe config.programs.neomutt.package}";
    icon = "kitty";
    categories = [
      "Network"
      "Email"
    ];
    comment = "Terminal email client";
    terminal = false;
    type = "Application";
  };
in
{
  config = lib.mkIf config.communication.neomutt.enable {
    xdg.mimeApps.defaultApplications = {
      "x-scheme-handler/mailto" = "neomutt.desktop";
    };
    home.packages = with pkgs; [
      urlscan
      neomuttDesktopItem
    ];
    xdg.configFile."neomutt/mailcap".text = ''
      text/html; ${lib.getExe' config.web.w3m.package "w3m"} -dump -cols 100 -T text/html '%s'; copiousoutput; nametemplate=%s.html
      image/*; xdg-open '%s' &
      application/pdf; xdg-open '%s'; nametemplate=%s.pdf
      video/*; xdg-open '%s' &
      audio/*; xdg-open '%s' &
      application/*; xdg-open '%s' &
    '';
    xdg.configFile."neomutt/flag_legend.txt".text = ''
      NeoMutt Index Flags
      ===================
      Message state ($flag_chars) -- unchanged defaults
        N   New       - unread, arrived since you last checked
        O   Old       - unread, but seen in a previous session
        D   Deleted   - marked for deletion (pending expunge)
        d   Att-del   - has attachments marked for deletion
        !   Flagged   - important (toggle with F)
        *   Tagged    - selected for a bulk operation (toggle with t)
        r   Replied   - you've replied to this message
        (blank)       - read, nothing else notable
      Cryptography ($crypt_chars)
           Verified   - signed, and the signature checks out
           Encrypted  - PGP/SMIME encrypted
           Signed     - PGP/SMIME signed (unverified)
           PGP key    - message contains a PGP public key
        (blank)         - no cryptography info
      Addressing ($to_chars)
           To you only      - sent to you and only you
           To (with others) - you're in the To: list, among others
           Cc only          - you're only in the Cc: list
           From you         - sent by you
           Mailing list     - sent to a list you're subscribed to
        (blank)              - not in To/Cc (e.g. Bcc, unlisted)
      Press q to close.
    '';
    programs.neomutt = {
      enable = true;
      sidebar.enable = true;
      sort = "reverse-threads";
      vimKeys = true;
      unmailboxes = true;
      checkStatsInterval = 20;
      extraConfig = builtins.readFile ./.neomuttrc;
    };
  };
}