]> Git — Sourcephile - julm/julm-nix.git/blob - homes/julm/mails.nix
mails: test notmuch setup
[julm/julm-nix.git] / homes / julm / mails.nix
1 { pkgs, lib, config, ... }:
2
3 with lib;
4 {
5 config = mkMerge [
6 {
7 accounts.email = {
8 maildirBasePath = "mail/accounts";
9 accounts."testbox" = {
10 primary = true;
11 address = "testbox@sourcephile.fr";
12 userName = "testbox@sourcephile.fr";
13 realName = "Test Box";
14 passwordCommand = "${pkgs.coreutils}/bin/cat /home/julm/mail/accounts/testbox.pass";
15 #passwordCommand = "${pkgs.pass}/bin/pass sourcephile/mail/julm";
16 #passwordCommand = "${pkgs.gnupg}/bin/gpg -q --for-your-eyes-only --no-tty --exit-on-status-write-error --batch --passphrase-file ${config.home.homeDirectory}/sync/rh.pass -d ${config.home.homeDirectory}/desktop/documents/rh.pass.gpg";
17 imap.host = "mail.sourcephile.fr";
18 smtp.host = "mail.sourcephile.fr";
19 astroid.enable = true;
20 mbsync = {
21 enable = true;
22 create = "both";
23 expunge = "both";
24 patterns = [ "*" ];
25 extraConfig = {
26 channel = {
27 Sync = "All";
28 };
29 account = {
30 Timeout = 120;
31 PipelineDepth = 1;
32 };
33 };
34 };
35 msmtp.enable = true;
36 notmuch.enable = true;
37 };
38 };
39 home.file."bin/msmtp" = {
40 executable = true;
41 text = ''
42 #!${pkgs.stdenv.shell}
43 ${pkgs.libnotify}/bin/notify-send "Sending mail ✉️"
44 ${pkgs.msmtp}/bin/msmtp --read-envelope-from $@
45 '';
46 };
47 programs.msmtp.enable = true;
48 home.packages = [
49 pkgs.alot
50 ];
51 }
52
53 (mkIf true {
54 services.mbsync = {
55 enable = true;
56 preExec = "${config.xdg.configHome}/mbsync/preExec";
57 postExec = "${config.xdg.configHome}/mbsync/postExec";
58 frequency = "*:0/30";
59 };
60 xdg.configFile."mbsync/preExec".source = pkgs.writeShellScript "mbsync-preExec" ''
61 export NOTMUCH_PROFILE=default
62 export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/$NOTMUCH_PROFILE/config
63 export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug
64
65 set -x
66 ${pkgs.coreutils}/bin/mkdir -p ${config.home.homeDirectory}/mail/accounts
67 ${pkgs.afew}/bin/afew --move-mails --verbose
68 '';
69 xdg.configFile."mbsync/postExec".source = pkgs.writeShellScript "mbsync-postExec" ''
70 export NOTMUCH_PROFILE=default
71 export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/$NOTMUCH_PROFILE/config
72 export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug
73
74 set -x
75 ${pkgs.notmuch}/bin/notmuch new
76 ${pkgs.afew}/bin/afew --tag --new --verbose
77 # Remove inbox (lower-case)
78 #${pkgs.notmuch}/bin/notmuch tag -inbox -- tag:inbox
79 # Remove Inbox tagged message that are not in an Inbox
80 #${pkgs.notmuch}/bin/notmuch tag -Inbox -- not folder:perso/Inbox and tag:Inbox
81 ${pkgs.libnotify}/bin/notify-send "Mails synced 📬"
82 '';
83 home.file."bin/msync".source = pkgs.writeShellScript "msync" ''
84 ${pkgs.libnotify}/bin/notify-send "Syncing mails 📫️"
85 systemctl --user start mbsync
86 '';
87 programs.mbsync.enable = true;
88 programs.notmuch.enable = true;
89 programs.afew = {
90 enable = true;
91 extraConfig = ''
92 [SpamFilter]
93 [KillThreadsFilter]
94 [MeFilter]
95 [ListMailsFilter]
96 [ArchiveSentMailsFilter]
97 sent_tag = sent
98 [FolderNameFilter]
99 maildir_separator = /
100 [InboxFilter]
101
102 [MailMover]
103 folders = Junk
104 rename = true
105
106 Junk = 'NOT tag:spam':INBOX
107 '';
108 };
109 programs.astroid = {
110 enable = true;
111 externalEditor = "emacsclient -c";
112 extraConfig = {
113 startup.queries.new = "tag:new";
114 startup.queries.inbox = "tag:inbox";
115 startup.queries.testbox = "to:testbox";
116 startup.queries.mail = "folder:mail/accounts/testbox";
117 };
118 };
119 })
120 ];
121 }