about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-04-03 11:57:32 -0700
committerFranck Cuny <franck@fcuny.net>2022-04-03 11:57:32 -0700
commit0ef7c9831c46656ea701c6596db2faa882fd925a (patch)
tree36637ec03cff7ca7e1e9e13e0c07dcacbc5070a2
parentsimplify multimedia for the desktop (diff)
downloadworld-0ef7c9831c46656ea701c6596db2faa882fd925a.tar.gz
email: use afew to filter emails
This is still not working as I want, will need more iteration.
-rw-r--r--users/fcuny/desktop/trust/email.nix42
1 files 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";
     };