{ pkgs, secrets, fleetFlake, lib, ... }: { programs.mbsync.enable = true; programs.msmtp.enable = true; services.mbsync = { enable = true; postExec = lib.getExe ( pkgs.writeShellScriptBin "mbsync-post-exec" '' ${lib.getExe pkgs.notmuch} new for _ in _ _ do afew -C ~/.config/notmuch/default/config --tag --new -vv afew -C ~/.config/notmuch/default/config --move --new -vv done '' ); }; home.file.".config/aerc/stylesets" = let catppuccin-aerc = pkgs.fetchFromGitHub { owner = "catppuccin"; repo = "aerc"; rev = "ca404a9f2d125ef12db40db663d43c9d94116a05"; hash = "sha256-OWIkHsKFts/zkrDUtbBPXHVSrHL/F0v3LB1rnlFAKmE="; }; in { source = "${catppuccin-aerc}/dist"; recursive = true; }; programs.aerc = { enable = true; extraBinds = { global = { "" = ":prev-tab"; "" = ":next-tab"; "?" = ":help keys"; }; messages = { "h" = ":prev-tab"; "l" = ":next-tab"; "j" = ":next"; "" = ":next"; "" = ":next 50%"; "" = ":next 100%"; "" = ":next 100%"; "k" = ":prev"; "" = ":prev"; "" = ":prev 50%"; "" = ":prev 100%"; "" = ":prev 100%"; "g" = ":select 0"; "G" = ":select -1"; "J" = ":next-folder"; "K" = ":prev-folder"; "H" = ":collapse-folder"; "L" = ":expand-folder"; "v" = ":mark -t"; "x" = ":mark -t:next"; "V" = ":mark -v"; "T" = ":toggle-threads"; "" = ":view"; "d" = ":prompt 'Really delete this message?' 'delete-message'"; "D" = ":delete"; "A" = ":archive flat"; "C" = ":compose"; "rr" = ":reply -a"; "rq" = ":reply -aq"; "Rr" = ":reply"; "Rq" = ":reply -q"; "c" = ":cf"; "$" = ":term"; "!" = ":term"; "|" = ":pipe"; "/" = ":search"; "\\" = ":filter"; "n" = ":next-result"; "N" = ":prev-result"; "" = ":clear"; }; "messages:folder=Drafts" = { "" = ":recall"; }; view = { "/" = ":toggle-key-passthrough/"; "q" = ":close"; "O" = ":open"; "S" = ":save"; "|" = ":pipe"; "D" = ":delete"; "A" = ":archive flat"; "" = ":open-link "; "f" = ":forward"; "rr" = ":reply -a"; "rq" = ":reply -aq"; "Rr" = ":reply"; "Rq" = ":reply -q"; "H" = ":toggle-headers"; "" = ":prev-part"; "" = ":next-part"; "J" = ":next"; "K" = ":prev"; }; "view::passthrough" = { "$noinherit" = true; "$ex" = ""; "" = ":toggle-key-passthrough"; }; compose = { "$noinherit" = "true"; "$ex" = ""; "" = ":prev-field"; "" = ":next-field"; "" = ":switch-account -p"; "" = ":switch-account -n"; "" = ":next-field"; "" = ":prev-tab"; "" = ":next-tab"; }; "compose::editor" = { "$noinherit" = "true"; "$ex" = ""; "" = ":prev-field"; "" = ":next-field"; "" = ":prev-tab"; "" = ":next-tab"; }; "compose::review" = { "y" = ":send"; "n" = ":abort"; "p" = ":postpone"; "q" = ":choose -o d discard abort -o p postpone postpone"; "e" = ":edit"; "a" = ":attach"; "d" = ":detach"; }; terminal = { "$noinherit" = "true"; "$ex" = ""; "" = ":prev-tab"; "" = ":next-tab"; }; }; extraConfig = { general.unsafe-accounts-conf = true; ui = { styleset-name = "catppuccin-mocha"; this-day-time-format = ''" 15:04"''; this-year-time-format = "Mon Jan 02 15:04"; timestamp-format = "2006-01-02 15:04"; spinner = "[ ⡿ ],[ ⣟ ],[ ⣯ ],[ ⣷ ],[ ⣾ ],[ ⣽ ],[ ⣻ ],[ ⢿ ]"; border-char-vertical = "┃"; border-char-horizontal = "━"; }; viewer = { always-show-mime = true; }; compose = { no-attachment-warning = "^[^>]*attach(ed|ment)"; }; filters = { "text/plain" = "colorize"; "text/html" = "html"; "text/calendar" = "calendar"; "message/delivery-status" = "colorize"; "message/rfc822" = "colorize"; "image/*" = "${pkgs.catimg}/bin/catimg -"; }; }; }; programs.notmuch = { enable = true; new.tags = [ "new" ]; search.excludeTags = [ "trash" "deleted" "spam" ]; maildir.synchronizeFlags = true; }; programs.afew = { enable = true; extraConfig = '' [Filter.1] message = "Tag GitHub notifications" tags = +github query = from:noreply@github.com OR from:notifications@github.com [Filter.2] query = "folder:autistici/Inbox" tags = +autistici message = "Tag personal autistici emails" [Filter.3] query = "not folder:autistici/Inbox" tag = -new message = "Sanity check: remove the new tag for emails moved out from Inbox" [Filter.4] query = "not folder:autistici/Inbox" tag = -new message = "Sanity check: remove the new tag for emails moved out from Inbox" [Filter.5] query = "not folder:autistici/Sent" tag = +sent message = "Sanity check: add the sent tag for emails in Sent" [Filter.6] query = "not folder:autistici/Drafts" tag = +draft message = "Sanity check: add the draft tag for emails in Draft" [MailMover] folders = autistici/Inbox rename = true autistici/Inbox = 'tag:archive':autistici/Archive 'tag:github':autistici/GitHub 'NOT tag:new':autistici/Trash ''; }; systemd.user.services.emails-watcher = { Unit.Description = "Send notifications when new emails arrive"; Install = { WantedBy = [ "default.target" ]; }; Service = { ExecStart = "${lib.getExe fleetFlake.packages.${pkgs.system}.emails-watcher}"; Environment = [ "INBOX_NEW=~/Maildir/autistici/Inbox/new" ]; }; }; accounts.email = { accounts.autistici = { aerc.enable = true; address = "andrea.ciceri@autistici.org"; gpg = { key = "7A66EEA1E6C598D07D361287A1FC89532D1C565"; signByDefault = true; }; imap = { host = "mail.autistici.org"; port = 993; }; mbsync = { enable = true; create = "maildir"; expunge = "both"; remove = "both"; }; msmtp.enable = true; notmuch.enable = true; primary = true; realName = "Andrea Ciceri"; signature = { text = '' Andrea Ciceri ''; showSignature = "append"; }; passwordCommand = "${pkgs.coreutils}/bin/cat ${secrets.autistici-password.path}"; smtp = { host = "smtp.autistici.org"; }; userName = "andrea.ciceri@autistici.org"; }; accounts.mlabs = { address = "andreaciceri@mlabs.city"; imap = { host = "imap.gmail.com"; port = 993; }; realName = "Andrea Ciceri"; smtp.host = "smtp.gmail.com"; userName = "andreaciceri@mlabs.city"; }; }; }