{ pkgs, config, lib, ... }: let inherit (import ../lib/email.nix) defaults; in { age.secrets = { email-password-cock = { file = ../secrets/email-password-cock.age; owner = config.users.users.me.name; group = config.users.users.me.group; mode = "400"; }; email-password-posteo = { file = ../secrets/email-password-posteo.age; owner = config.users.users.me.name; group = config.users.users.me.group; mode = "400"; }; }; home-manager.users.me = { services.mbsync = { enable = true; frequency = "daily"; preExec = "${pkgs.coreutils}/bin/mkdir -p ${config.home-manager.users.me.accounts.email.maildirBasePath}"; postExec = "${pkgs.notmuch}/bin/notmuch new"; }; programs.notmuch = { enable = true; extraConfig = { database.path = config.home-manager.users.me.accounts.email.maildirBasePath; new.tags = ""; user.name = defaults.realName; user.primary_email = config.home-manager.users.me.accounts.email.accounts.posteo.address; }; }; programs.mbsync = { enable = true; extraConfig = lib.concatStringsSep "\n\n" (lib.mapAttrsToList (name: account: '' IMAPAccount ${name} CertificateFile /etc/ssl/certs/ca-certificates.crt Host ${account.imap.host} PassCmd "${toString account.passwordCommand}" User ${account.userName} SSLType IMAPS ${lib.optionalString (lib.isInt account.imap.port) "Port ${toString account.imap.port}"} IMAPStore ${name}-remote Account ${name} MaildirStore ${name}-local Path ${config.home-manager.users.me.accounts.email.maildirBasePath}/${name}/ SubFolders Verbatim Channel ${name} Create Near Expunge None Far :${name}-remote: Near :${name}-local: Patterns * Remove None SyncState * '') config.home-manager.users.me.accounts.email.accounts); }; accounts.email.accounts = { cock = lib.recursiveUpdate defaults rec { address = "2210@cock.li"; userName = address; passwordCommand = "${pkgs.coreutils}/bin/cat ${config.age.secrets.email-password-cock.path}"; realName = ""; imap.host = "mail.cock.li"; smtp.host = imap.host; }; posteo = lib.recursiveUpdate defaults rec { address = "kieran.meinhardt@posteo.net"; aliases = ["kmein@posteo.de"]; userName = address; imap.host = "posteo.de"; smtp.host = imap.host; primary = true; passwordCommand = "${pkgs.coreutils}/bin/cat ${config.age.secrets.email-password-posteo.path}"; # himalaya = { enable = true; backend = "imap"; sender = "smtp"; }; }; }; # programs.himalaya.enable = true; programs.aerc = { enable = true; extraBinds = { # Binds are of the form = # To use '=' in a key sequence, substitute it with "Eq": "" # If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit global = { "" = ":prev-tab"; "" = ":next-tab "; "" = ":term"; "?" = ":help keys"; }; messages = { q = ":quit"; 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"; "" = ":read -t:next"; v = ":mark -t"; V = ":mark -v"; F = ":flag -t"; T = ":toggle-threads"; "" = ":view"; d = ":prompt 'Delete? ' 'delete-message'"; D = ":move Trash"; 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"; "*" = ":filter -x Flagged"; }; view = { "/" = ":toggle-key-passthrough /"; q = ":close"; O = ":open"; S = ":save"; "|" = ":pipe"; D = ":move Trash"; 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 = { # Keybindings used when the embedded terminal is not selected in the compose # view "$noinherit" = "true"; "$ex" = ""; "" = ":prev-field"; "" = ":next-field"; "" = ":next-field"; "" = ":prev-tab"; "" = ":next-tab"; }; "compose::editor" = { # Keybindings used when the embedded terminal is selected in the compose view "$noinherit" = "true"; "$ex" = ""; "" = ":prev-field"; "" = ":next-field"; "" = ":prev-tab"; "" = ":next-tab"; }; "compose::review" = { # Keybindings used when reviewing a message to be sent 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 = { ui.sort = "-r date"; ui.timestamp-format = "2006-01-02 15:04"; ui.mouse-enabled = true; ui.spinner = ". , ."; general.unsafe-accounts-conf = true; general.pgp-provider = "gpg"; viewer = {pager = "${pkgs.less}/bin/less -R";}; compose = { address-book-cmd = "khard email --remove-first-line --parsable '%s'"; no-attachment-warning = "(attach|attached|attachments?|anbei|Anhang|angehÃĪngt)"; }; filters = { "text/plain" = "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize"; "text/calendar" = "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/calendar"; "text/html" = "${pkgs.aerc}/share/aerc/filters/html"; # Requires w3m, dante # "text/html" = # "${pkgs.aerc}/share/aerc/filters/html | ${pkgs.aerc}/share/aerc/filters/colorize"; # "text/*" = # ''${pkgs.bat}/bin/bat -fP --theme=ansi --file-name="$AERC_FILENAME "''; "message/delivery-status" = "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize"; "message/rfc822" = "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize"; "application/x-sh" = "${pkgs.bat}/bin/bat -fP -l sh"; }; openers = let as-pdf = pkgs.writers.writeDash "as-pdf" '' d=$(mktemp -d) trap clean EXIT clean() { rm -rf "$d" } ${pkgs.libreoffice}/bin/libreoffice --headless --convert-to pdf "$1" --outdir "$d" ${pkgs.zathura}/bin/zathura "$d"/*.pdf ''; in { "image/*" = "${pkgs.nsxiv}/bin/nsxiv"; "application/pdf" = "${pkgs.zathura}/bin/zathura"; "application/vnd.openxmlformats-officedocument.wordprocessingml.document" = toString as-pdf; "application/vnd.oasis.opendocument.text" = toString as-pdf; "video/*" = "${pkgs.mpv}/bin/mpv"; "audio/*" = "${pkgs.mpv}/bin/mpv"; }; }; templates = { # new_message = "hello!"; }; }; }; }