aboutsummaryrefslogtreecommitdiffstats
path: root/modules/communication/neomutt/neomutt.nix
blob: e25d0b39fc4d5fa61861a7e51f2187af8a0088d1 (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
# Terminal email client
{
  config,
  lib,
  pkgs,
  ...
}:
{
  config = lib.mkIf config.communication.neomutt.enable {
    xdg.desktopEntries."neomutt" = {
      name = "NeoMutt";
      exec = "${lib.getExe config.terminal.kitty.package} --class neomutt -e ${lib.getExe config.programs.neomutt.package}";
      icon = "${config.programs.neomutt.package}/share/neomutt/logo/neomutt.svg";
      categories = [
        "Network"
        "Email"
      ];
      comment = "Terminal email client";
      terminal = false;
      type = "Application";
    };
    xdg.mimeApps.defaultApplications = {
      "x-scheme-handler/mailto" = "neomutt.desktop";
    };
    xdg.configFile."neomutt/mailcap".text = ''
      text/html; ${lib.getExe config.web.chawan.package} -o "title='neomutt'" '%s'; 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' &
    '';
    programs.neomutt = {
      enable = true;
      package = pkgs.symlinkJoin {
        name = "neomutt-wrapped";
        paths = [ pkgs.neomutt ];
        nativeBuildInputs = [ pkgs.makeWrapper ];
        postBuild = ''
          wrapProgram $out/bin/neomutt \
            --prefix PATH : ${lib.makeBinPath [ pkgs.urlscan ]}
        '';
        meta.mainProgram = "neomutt";
      };
      sidebar.enable = true;
      sort = "reverse-threads";
      vimKeys = false;
      unmailboxes = true;
      checkStatsInterval = 20;
      extraConfig = builtins.readFile ./.neomuttrc;
    };
  };
}