aboutsummaryrefslogtreecommitdiffstats
path: root/modules/communication/neomutt/default.nix
blob: 4bd180018ffcbc5d69390b5a53fb4ca467e963fc (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
# Neomutt - Email suite entry point (neomutt + mbsync + notmuch)
{
  config,
  lib,
  pkgs,
  ...
}:
{
  imports = [
    ./account
    ./sync
    ./assertions.nix
    ./keybindings.nix
    ./macros.nix
    ./neomutt.nix
  ];

  options.communication.neomutt = {
    enable = lib.mkEnableOption "Email suite (neomutt + mbsync + notmuch)";

    package = lib.mkOption {
      type = lib.types.package;
      default = 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";
      };
      defaultText = lib.literalExpression ''
        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";
        }
      '';
      description = "The neomutt package to use, wrapped with urlscan in PATH.";
    };
  };

  config = lib.mkIf config.communication.neomutt.enable {
    accounts.email.maildirBasePath = "${config.home.homeDirectory}/.local/share/mail";
    home.sessionVariables.MAILDIR = config.accounts.email.maildirBasePath;
  };
}