update email settings
This commit is contained in:
parent
9dca602bd1
commit
fb5a779c9e
|
@ -1,43 +1,82 @@
|
|||
{ pkgs, ... }: {
|
||||
accounts.email.accounts =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
mkAccount = username: host: passName: {
|
||||
realName = "Leonardo Eugênio";
|
||||
address = "${username}@${host}";
|
||||
userName = username;
|
||||
|
||||
downloadEmails = "${pkgs.offlineimap}/bin/offlineimap";
|
||||
afterSync = "${pkgs.notmuch}/bin/notmuch new";
|
||||
onNewEmails = "${pkgs.libnotify}/bin/notify-send 'You've got mail!'";
|
||||
|
||||
defaultAccountSettings = {
|
||||
astroid.enable = true;
|
||||
imap.host = host;
|
||||
smtp.host = host;
|
||||
imapnotify = {
|
||||
enable = true;
|
||||
onNotify = "${pkgs.isync}/bin/mbsync -a";
|
||||
onNotifyPost =
|
||||
"${pkgs.notmuch}/bin/notmuch new && ${pkgs.libnotify}/bin/ notify-send 'New mail arrived'";
|
||||
boxes = [ "INBOX" ];
|
||||
onNotify = downloadEmails;
|
||||
onNotifyPost = afterSync;
|
||||
};
|
||||
mbsync = {
|
||||
offlineimap = {
|
||||
enable = true;
|
||||
create = "both";
|
||||
postSyncHookCommand = afterSync;
|
||||
};
|
||||
msmtp.enable = true;
|
||||
notmuch.enable = true;
|
||||
passwordCommand = toString (pkgs.writeShellScript "get_pass" ''
|
||||
pass ${passName} | head -n1
|
||||
'');
|
||||
};
|
||||
in
|
||||
{
|
||||
"personal" = (mkAccount "lelgenio" "disroot.org" "disroot.org") // { primary = true; };
|
||||
"work" = mkAccount "leonardo" "wopus.com.br" "Trabalho/wopus_email/leonardo@wopus.com.br";
|
||||
accounts.email.accounts =
|
||||
{
|
||||
"personal" = {
|
||||
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;
|
||||
|
||||
programs.mbsync.enable = true;
|
||||
services.mbsync.enable = true;
|
||||
services.mbsync.postExec = "${pkgs.notmuch}/bin/notmuch new";
|
||||
programs.offlineimap.enable = true;
|
||||
systemd.user.services.offlineimap = {
|
||||
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.hooks.postInsert = onNewEmails;
|
||||
|
||||
programs.msmtp.enable = true;
|
||||
|
||||
programs.astroid.enable = true;
|
||||
programs.astroid = {
|
||||
enable = true;
|
||||
externalEditor = "terminal -e kak %1";
|
||||
pollScript = downloadEmails;
|
||||
extraConfig = { };
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue