nixos-config/user/email.nix

85 lines
2.2 KiB
Nix
Raw Normal View History

2023-01-22 23:11:57 -03:00
{ pkgs, ... }:
let
downloadEmails = "${pkgs.offlineimap}/bin/offlineimap";
afterSync = "${pkgs.notmuch}/bin/notmuch new";
2023-01-22 23:59:01 -03:00
onNewEmails = ''
${pkgs.libnotify}/bin/notify-send "You've got mail!"
'';
2023-01-22 23:11:57 -03:00
defaultAccountSettings = {
astroid.enable = true;
imapnotify = {
enable = true;
boxes = [ "INBOX" ];
onNotify = downloadEmails;
onNotifyPost = afterSync;
};
offlineimap = {
enable = true;
postSyncHookCommand = afterSync;
};
msmtp.enable = true;
notmuch.enable = true;
};
in
{
2023-01-22 18:12:04 -03:00
accounts.email.accounts =
2023-01-22 23:11:57 -03:00
{
"personal" = {
primary = true;
2023-01-22 18:12:04 -03:00
realName = "Leonardo Eugênio";
2023-01-22 23:11:57 -03:00
address = "lelgenio@disroot.org";
userName = "lelgenio";
imap.host = "disroot.org";
smtp.host = "disroot.org";
2023-01-22 18:12:04 -03:00
passwordCommand = toString (pkgs.writeShellScript "get_pass" ''
2023-01-22 23:11:57 -03:00
pass "disroot.org" | head -n1
2023-01-22 18:12:04 -03:00
'');
2023-01-22 23:11:57 -03:00
} // 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;
2023-01-22 02:13:10 -03:00
};
services.imapnotify.enable = true;
2023-01-22 23:11:57 -03:00
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" ]; };
};
2023-01-22 02:13:10 -03:00
programs.notmuch.enable = true;
2023-01-22 23:11:57 -03:00
programs.notmuch.hooks.postInsert = onNewEmails;
2023-01-22 02:13:10 -03:00
programs.msmtp.enable = true;
2023-01-22 23:11:57 -03:00
programs.astroid = {
enable = true;
2023-01-24 10:07:04 -03:00
externalEditor = "terminal -e $EDITOR %1";
2023-01-22 23:11:57 -03:00
pollScript = downloadEmails;
extraConfig = { };
};
2023-01-22 02:13:10 -03:00
}