--- /dev/null
+{ pkgs, lib, config, ... }:
+
+with lib;
+{
+config = mkMerge [
+ {
+ accounts.email = {
+ maildirBasePath = "mail/accounts";
+ accounts."testbox" = {
+ primary = true;
+ address = "testbox@sourcephile.fr";
+ userName = "testbox@sourcephile.fr";
+ realName = "Test Box";
+ passwordCommand = "${pkgs.coreutils}/bin/cat /home/julm/mail/accounts/testbox.pass";
+ #passwordCommand = "${pkgs.pass}/bin/pass sourcephile/mail/julm";
+ #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";
+ imap.host = "mail.sourcephile.fr";
+ smtp.host = "mail.sourcephile.fr";
+ astroid.enable = true;
+ mbsync = {
+ enable = true;
+ create = "both";
+ expunge = "both";
+ patterns = [ "*" ];
+ extraConfig = {
+ channel = {
+ Sync = "All";
+ };
+ account = {
+ Timeout = 120;
+ PipelineDepth = 1;
+ };
+ };
+ };
+ msmtp.enable = true;
+ notmuch.enable = true;
+ };
+ };
+ home.file."bin/msmtp" = {
+ executable = true;
+ text = ''
+ #!${pkgs.stdenv.shell}
+ ${pkgs.libnotify}/bin/notify-send "Sending mail ✉️"
+ ${pkgs.msmtp}/bin/msmtp --read-envelope-from $@
+ '';
+ };
+ programs.msmtp.enable = true;
+ home.packages = [
+ pkgs.alot
+ ];
+ }
+
+ (mkIf true {
+ services.mbsync = {
+ enable = true;
+ preExec = "${config.xdg.configHome}/mbsync/preExec";
+ postExec = "${config.xdg.configHome}/mbsync/postExec";
+ frequency = "*:0/30";
+ };
+ xdg.configFile."mbsync/preExec".source = pkgs.writeShellScript "mbsync-preExec" ''
+ export NOTMUCH_PROFILE=default
+ export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/$NOTMUCH_PROFILE/config
+ export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug
+
+ set -x
+ ${pkgs.coreutils}/bin/mkdir -p ${config.home.homeDirectory}/mail/accounts
+ ${pkgs.afew}/bin/afew --move-mails --verbose
+ '';
+ xdg.configFile."mbsync/postExec".source = pkgs.writeShellScript "mbsync-postExec" ''
+ export NOTMUCH_PROFILE=default
+ export NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/$NOTMUCH_PROFILE/config
+ export NMBGIT=${config.xdg.dataHome}/notmuch/nmbug
+
+ set -x
+ ${pkgs.notmuch}/bin/notmuch new
+ ${pkgs.afew}/bin/afew --tag --new --verbose
+ # Remove inbox (lower-case)
+ #${pkgs.notmuch}/bin/notmuch tag -inbox -- tag:inbox
+ # Remove Inbox tagged message that are not in an Inbox
+ #${pkgs.notmuch}/bin/notmuch tag -Inbox -- not folder:perso/Inbox and tag:Inbox
+ ${pkgs.libnotify}/bin/notify-send "Mails synced 📬"
+ '';
+ home.file."bin/msync".source = pkgs.writeShellScript "msync" ''
+ ${pkgs.libnotify}/bin/notify-send "Syncing mails 📫️"
+ systemctl --user start mbsync
+ '';
+ programs.mbsync.enable = true;
+ programs.notmuch.enable = true;
+ programs.afew = {
+ enable = true;
+ extraConfig = ''
+ [SpamFilter]
+ [KillThreadsFilter]
+ [MeFilter]
+ [ListMailsFilter]
+ [ArchiveSentMailsFilter]
+ sent_tag = sent
+ [FolderNameFilter]
+ maildir_separator = /
+ [InboxFilter]
+
+ [MailMover]
+ folders = Junk
+ rename = true
+
+ Junk = 'NOT tag:spam':INBOX
+ '';
+ };
+ programs.astroid = {
+ enable = true;
+ externalEditor = "emacsclient -c";
+ extraConfig = {
+ startup.queries.new = "tag:new";
+ startup.queries.inbox = "tag:inbox";
+ startup.queries.testbox = "to:testbox";
+ startup.queries.mail = "folder:mail/accounts/testbox";
+ };
+ };
+ })
+];
+}