blob: 183e5ffe4fc6d7f4a635c2d69b31333c27fec8d3 (
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
|
{ config, lib, ... }:
with lib;
let
inherit (lib) types;
in
{
options.communication.neomutt.accounts = mkOption {
type = types.attrsOf (
types.submodule {
imports = [
./options.nix
./flavors/gmail.nix
];
}
);
default = { };
description = "Specification of email accounts.";
};
config = mkIf config.communication.neomutt.enable {
accounts.email.accounts = mapAttrs (
name: account:
let
a = account;
in
{
inherit (a) realName address primary;
userName = if a.userName != null then a.userName else a.address;
passwordCommand =
if a.passwordGopassSecret != null then
"${lib.getExe config.security.gopass.package} -o ${a.passwordGopassSecret}"
else
null;
flavor = a.flavor;
inherit (a) aliases;
folders = {
inherit (a.folders) inbox trash;
}
// optionalAttrs (a.folders.drafts != null) { drafts = a.folders.drafts; }
// optionalAttrs (a.folders.sent != null) { sent = a.folders.sent; };
neomutt = {
enable = true;
mailboxType = a.neomutt.mailboxType;
extraConfig = a.neomutt.extraConfig;
};
mbsync = {
enable = true;
create = a.mbsync.create;
patterns = a.mbsync.patterns;
flatten = a.mbsync.flatten;
extraConfig = {
account = a.mbsync.extraConfig.account;
channel = a.mbsync.extraConfig.channel;
local = a.mbsync.extraConfig.local;
remote = a.mbsync.extraConfig.remote;
};
};
notmuch = {
enable = true;
neomutt = {
enable = true;
virtualMailboxes = a.notmuch.neomutt.virtualMailboxes;
};
};
imap = optionalAttrs (a.imap.host != null) {
host = a.imap.host;
port = a.imap.port;
tls = {
enable = a.imap.tls.enable;
useStartTls = a.imap.tls.useStartTls;
};
};
smtp = optionalAttrs (a.smtp.host != null) {
host = a.smtp.host;
port = a.smtp.port;
tls = {
enable = a.smtp.tls.enable;
useStartTls = a.smtp.tls.useStartTls;
};
};
gpg = optionalAttrs (a.gpg.key != null) {
key = a.gpg.key;
signByDefault = a.gpg.signByDefault;
encryptByDefault = a.gpg.encryptByDefault;
};
signature = optionalAttrs (a.signature.text != null || a.signature.command != null) {
text = a.signature.text;
command = a.signature.command;
showSignature = a.signature.showSignature;
};
}
) (filterAttrs (n: a: a.enable) config.communication.neomutt.accounts);
};
}
|