update email settings

This commit is contained in:
Leonardo Eugênio 2023-01-22 23:11:57 -03:00
parent 9dca602bd1
commit fb5a779c9e

View file

@ -1,43 +1,82 @@
{ pkgs, ... }: { { pkgs, ... }:
accounts.email.accounts = let
let
mkAccount = username: host: passName: { downloadEmails = "${pkgs.offlineimap}/bin/offlineimap";
realName = "Leonardo Eugênio"; afterSync = "${pkgs.notmuch}/bin/notmuch new";
address = "${username}@${host}"; onNewEmails = "${pkgs.libnotify}/bin/notify-send 'You've got mail!'";
userName = username;
defaultAccountSettings = {
astroid.enable = true; astroid.enable = true;
imap.host = host;
smtp.host = host;
imapnotify = { imapnotify = {
enable = true; enable = true;
onNotify = "${pkgs.isync}/bin/mbsync -a"; boxes = [ "INBOX" ];
onNotifyPost = onNotify = downloadEmails;
"${pkgs.notmuch}/bin/notmuch new && ${pkgs.libnotify}/bin/ notify-send 'New mail arrived'"; onNotifyPost = afterSync;
}; };
mbsync = { offlineimap = {
enable = true; enable = true;
create = "both"; postSyncHookCommand = afterSync;
}; };
msmtp.enable = true; msmtp.enable = true;
notmuch.enable = true; notmuch.enable = true;
passwordCommand = toString (pkgs.writeShellScript "get_pass" ''
pass ${passName} | head -n1
'');
}; };
in in
{
accounts.email.accounts =
{ {
"personal" = (mkAccount "lelgenio" "disroot.org" "disroot.org") // { primary = true; }; "personal" = {
"work" = mkAccount "leonardo" "wopus.com.br" "Trabalho/wopus_email/leonardo@wopus.com.br"; primary = true;
realName = "Leonardo Eugênio";
address = "lelgenio@disroot.org";
userName = "lelgenio";
imap.host = "disroot.org";
smtp.host = "disroot.org";
passwordCommand = toString (pkgs.writeShellScript "get_pass" ''
pass "disroot.org" | head -n1
'');
} // defaultAccountSettings;
"work" = {
realName = "Leonardo Eugênio";
address = "leonardo@wopus.com.br";
userName = "leonardo@wopus.com.br";
imap.host = "imap.wopus.com.br";
smtp.host = "smtp.wopus.com.br";
passwordCommand = toString (pkgs.writeShellScript "get_pass" ''
pass "Trabalho/wopus_email/leonardo@wopus.com.br" | head -n1
'');
} // defaultAccountSettings;
}; };
services.imapnotify.enable = true; services.imapnotify.enable = true;
programs.mbsync.enable = true; programs.offlineimap.enable = true;
services.mbsync.enable = true; systemd.user.services.offlineimap = {
services.mbsync.postExec = "${pkgs.notmuch}/bin/notmuch new"; Unit = {
Description = "offlineimap mailbox synchronization";
};
Service = {
Type = "oneshot";
ExecStart = downloadEmails;
};
};
systemd.user.timers.offlineimap = {
Unit = { Description = "offlineimap mailbox synchronization"; };
Timer = {
OnCalendar = "*:0/5";
Unit = "offlineimap.service";
};
Install = { WantedBy = [ "timers.target" ]; };
};
programs.notmuch.enable = true; programs.notmuch.enable = true;
programs.notmuch.hooks.postInsert = onNewEmails;
programs.msmtp.enable = true; programs.msmtp.enable = true;
programs.astroid.enable = true; programs.astroid = {
enable = true;
externalEditor = "terminal -e kak %1";
pollScript = downloadEmails;
extraConfig = { };
};
} }