-
Notifications
You must be signed in to change notification settings - Fork 0
/
accounts.nix
220 lines (185 loc) · 5.07 KB
/
accounts.nix
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
{
config,
osConfig,
pkgs,
...
}: let
inherit (osConfig.lajp.user) realName;
mkSchool = {
name,
address,
userName ? address,
}: {
inherit address userName realName;
msmtp = {
enable = true;
extraConfig.auth = "xoauth2";
};
# NOTE: setup the oauth with the mutt_oauth2.py script
# https://www.vanormondt.net/~peter/blog/2021-03-16-mutt-office365-mfa.html
# Using the (old) Thunderbird oauth app
# client_id = 08162f7c-0fd2-4200-a84a-f25a4db0b584
# client_secret = TxRBilcHdC6WGBee]fs?QR:SJ8nI[g82
# use -t $PASSWORD_STORE_DIR/$address.gpg to get the path correct (for pass)
passwordCommand = let
python = "${pkgs.python3}/bin/python3";
mutt_oauth2 = "${pkgs.neomutt}/share/neomutt/oauth2/mutt_oauth2.py";
passDir = config.programs.password-store.settings.PASSWORD_STORE_DIR;
in "${python} ${mutt_oauth2} --encryption-pipe 'gpg -e -r ${address}' ${passDir}/${address}.gpg";
flavor = "outlook.office365.com";
mbsync = {
enable = true;
create = "maildir";
expunge = "maildir";
extraConfig.account.AuthMechs = "XOAUTH2";
};
gpg = {
encryptByDefault = true;
signByDefault = true;
};
maildir.path = address;
folders = {
sent = "Sent Items";
trash = "Deleted Items";
};
neomutt = {
enable = true;
extraMailboxes = ["Drafts" "Deleted Items" "Sent Items"];
extraConfig = ''
source ${config.xdg.configHome}/neomutt/sidebar/${name}
'';
};
notmuch = {
enable = true;
neomutt.enable = true;
};
};
mkGmail = {
name,
address,
aliases ? [],
}: {
inherit address realName aliases;
flavor = "gmail.com";
gpg = {
encryptByDefault = true;
signByDefault = true;
};
maildir.path = address;
msmtp = {
enable = true;
extraConfig.auth = "xoauth2";
};
mbsync = {
enable = true;
create = "maildir";
expunge = "maildir";
extraConfig.account.AuthMechs = "XOAUTH2";
};
neomutt = {
enable = true;
extraMailboxes = map (x: "[Gmail]/" + x) ["Drafts" "Trash" "Sent Mail"];
extraConfig = ''
${
if aliases != []
then "alternates ${toString aliases}"
else ""
}
source ${config.xdg.configHome}/neomutt/sidebar/${name}
'';
};
notmuch = {
enable = true;
neomutt.enable = true;
};
passwordCommand = let
python = "${pkgs.python3}/bin/python3";
mutt_oauth2 = "${pkgs.neomutt}/share/neomutt/oauth2/mutt_oauth2.py";
passDir = config.programs.password-store.settings.PASSWORD_STORE_DIR;
in "${python} ${mutt_oauth2} --encryption-pipe 'gpg -e -r [email protected]' ${passDir}/oauth/${address}.gpg";
folders = {
sent = "[Gmail]/Sent Mail";
drafts = "[Gmail]/Drafts";
trash = "[Gmail]/Trash";
};
};
in {
accounts.email.maildirBasePath = config.xdg.dataHome + "/mail";
accounts.email.accounts = {
personal = let
address = "[email protected]";
in {
msmtp.enable = true;
inherit address realName;
aliases = ["[email protected]"];
imap.host = "mail.lajp.fi";
mbsync = {
enable = true;
create = "maildir";
expunge = "maildir";
};
gpg = {
encryptByDefault = true;
signByDefault = true;
};
maildir.path = address;
neomutt = {
enable = true;
extraMailboxes = ["Drafts" "Junk" "Trash" "Sent" "Archive"];
extraConfig = ''
# This together with `set reverse_name` allows automatically
# determening the address from which to reply based on the
# recipient of the original mail
source ${config.xdg.configHome}/neomutt/sidebar/personal
'';
};
notmuch = {
enable = true;
neomutt.enable = true;
};
passwordCommand = "${pkgs.pass}/bin/pass ${address}";
userName = address;
primary = true;
smtp = {
host = "mail.lajp.fi";
port = 587;
tls.useStartTls = true;
};
};
# NOTE: this account is for sending only
# neomutt can use this when using msmtp --read-envelope-from
iki = let
address = "[email protected]";
in {
inherit address realName;
aliases = ["[email protected]"];
msmtp.enable = true;
passwordCommand = "${pkgs.pass}/bin/pass ${address}";
userName = address;
smtp = {
host = "smtp.iki.fi";
port = 587;
tls.useStartTls = true;
};
};
aalto = mkSchool {
name = "aalto";
address = "[email protected]";
};
hy = mkSchool {
name = "hy";
address = "[email protected]";
userName = "[email protected]";
};
otanix = mkGmail {
name = "otanix";
address = "[email protected]";
aliases = ["[email protected]"];
};
helsec = mkGmail {
name = "helsec";
address = "[email protected]";
};
};
}