From 0ef7c9831c46656ea701c6596db2faa882fd925a Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 3 Apr 2022 11:57:32 -0700 Subject: email: use afew to filter emails This is still not working as I want, will need more iteration. --- users/fcuny/desktop/trust/email.nix | 42 +++++++++++++++---------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/users/fcuny/desktop/trust/email.nix b/users/fcuny/desktop/trust/email.nix index ba20634..3bb6bd2 100644 --- a/users/fcuny/desktop/trust/email.nix +++ b/users/fcuny/desktop/trust/email.nix @@ -9,13 +9,14 @@ address = "franck@fcuny.net"; userName = address; realName = "Franck Cuny"; - aliases = [ "franck.cuny@gmail.com" ]; + aliases = [ "franck.cuny@gmail.com" ]; passwordCommand = "pass email/imap.fastmail.com"; imap.host = "imap.fastmail.com"; mbsync = { enable = true; create = "maildir"; expunge = "both"; + extraConfig.channel.CopyArrivalDate = "yes"; }; notmuch.enable = true; }; @@ -24,44 +25,35 @@ programs.mbsync.enable = true; + programs.afew = { + enable = true; + extraConfig = '' + [SpamFilter] + [KillThreadsFilter] + [ArchiveSentMailsFilter] + [InboxFilter] + ''; + }; + programs.notmuch = { enable = true; maildir.synchronizeFlags = true; new.tags = [ "unread" "inbox" ]; new.ignore = [ "Trash" ]; search.excludeTags = [ "spam" "deleted" ]; - }; - - xdg.configFile."notmuch/imap-sync.sh" = { - executable = true; - text = '' - #!${pkgs.stdenv.shell} - MAILDIR=$HOME/.mail/ - - # Strip UIDs from filenames when moving mails so that mbsync doesn't get confused. - mv_renamed() { - while IFS= read -r name; do - flags=$(echo "$name" | cut -d':' -f2) - new_name="$(basename $name | awk -F ',' '{print $1}')" - [ -f "$name" ] && mv -nv "$name" "$1/$new_name" - done - } - - ${pkgs.notmuch}/bin/notmuch search --output=files -- not tag:inbox and folder:Fastmail/Inbox | mv_renamed $MAILDIR/Fastmail/Archive/cur - ''; + hooks = { + postNew = "${config.home.profileDirectory}/bin/afew -v --tag --new"; + }; }; systemd.user.services.mbsync = { - Unit = { - Description = "mbsync synchronization"; - }; + Unit = { Description = "mbsync synchronization"; }; Service = { Type = "oneshot"; Environment = [ - "PASSWORD_STORE_DIR=${config.programs.password-store.settings.PASSWORD_STORE_DIR}" + "PASSWORD_STORE_DIR=${config.programs.password-store.settings.PASSWORD_STORE_DIR}" "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc" ]; - ExecStartPre = "${config.xdg.configHome}/notmuch/imap-sync.sh"; ExecStart = "${pkgs.isync}/bin/mbsync -a"; ExecStartPost = "${pkgs.notmuch}/bin/notmuch new --quiet"; }; -- cgit 1.4.1