diff --git a/users/simon/modules/mail/accounts.nix b/users/simon/modules/mail/accounts.nix deleted file mode 100644 index 6939ed5..0000000 --- a/users/simon/modules/mail/accounts.nix +++ /dev/null @@ -1,113 +0,0 @@ -{ config, ... }: -let - signaturePersonal = '' - -- - Simon Bruder - Appartement 149 - Güntzstraße 28/28a - 01307 Dresden - - 🔑 (GPG): 47E7 559E 037A 3565 2DBB F8AA 8D3C 82F9 F309 F8EC - 📧 (e-mail): simon@sbruder.de - 📱 (mobile): +49 152 56561414 - ''; -in -{ - accounts.email = { - maildirBasePath = "${config.xdg.dataHome}/mail"; - - accounts = { - personal = rec { - primary = true; - - realName = "Simon Bruder"; - address = "simon@sbruder.de"; - - userName = address; - passwordCommand = "pass sbruder.de/mail"; - - imap = { - host = "vueko.sbruder.de"; - tls.useStartTls = true; - }; - smtp = { - host = "vueko.sbruder.de"; - port = 587; - tls.useStartTls = true; - }; - - gpg = { - key = config.programs.gpg.settings.default-key; - signByDefault = true; - encryptByDefault = true; - }; - - signature.text = signaturePersonal; - - aerc-sbruder.enable = true; - mbsync = { - enable = true; - #flatten = "."; - create = "both"; - expunge = "both"; - }; - msmtp.enable = true; - notmuch.enable = true; - }; - riseup = rec { - realName = "Simon Bruder"; - address = "sbruder@riseup.net"; - - userName = address; - passwordCommand = "pass web/riseup.net | head -n 1"; - - imap = { - host = "mail.riseup.net"; - tls.useStartTls = true; - }; - smtp = { - host = "mail.riseup.net"; - port = 587; - tls.useStartTls = true; - }; - - gpg = { - key = config.programs.gpg.settings.default-key; - signByDefault = true; - encryptByDefault = true; - }; - - signature.text = signaturePersonal; - - aerc-sbruder.enable = true; - }; - tu-dresden = rec { - realName = "Simon Bruder"; - address = "simon.bruder@mailbox.tu-dresden.de"; - - userName = "user\\sibr833e"; - passwordCommand = "pass web/tu-dresden.de | head -n 1"; - - imap = { - host = "msx.tu-dresden.de"; - tls.useStartTls = true; - }; - smtp = { - host = "msx.tu-dresden.de"; - port = 587; - tls.useStartTls = true; - }; - - gpg = { - key = config.programs.gpg.settings.default-key; - signByDefault = true; - encryptByDefault = true; - }; - - signature.text = signaturePersonal; - - aerc-sbruder.enable = true; - }; - }; - }; -} diff --git a/users/simon/modules/mail/aerc/colorize b/users/simon/modules/mail/aerc/colorize deleted file mode 100755 index cd7956f..0000000 --- a/users/simon/modules/mail/aerc/colorize +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env -S awk -f -# Copyright (c) 2022 Robin Jarry -# Modified 2022-06-16 by Simon Bruder to use ANSI colors -# Modified 2022-06-16 by Simon Bruder to a /usr/bin/env shebang - -BEGIN { - url = "\x1b[33m" # yellow - header = "\x1b[35m" # purple - signature = "\x1b[35m" # purple - diff_meta = "\x1b[1;37m" # bold white - diff_chunk = "\x1b[36m" # cyan - diff_add = "\x1b[32m" # green - diff_del = "\x1b[31m" # red - quote_1 = "\x1b[34m" # blue - quote_2 = "\x1b[91m" # orange - quote_3 = "\x1b[35m" # purple - quote_4 = "\x1b[95m" # pink - quote_x = "\x1b[37m" # gray - reset = "\x1b[0m" - # state - in_diff = 0 - in_signature = 0 - in_headers = 0 - in_body = 0 - # patterns - header_pattern = @/^[A-Z][[:alnum:]-]+:/ - url_pattern = @/[a-z]{2,6}:\/\/[[:graph:]]+|(mailto:)?[[:alnum:]_\+\.~\/-]*[[:alnum:]_]@[[:lower:]][[:alnum:]\.-]*[[:lower:]]/ -} -function color_quote(line) { - level = 0 - quotes = "" - while (line ~ /^>/) { - level += 1 - quotes = quotes ">" - line = substr(line, 2) - while (line ~ /^ /) { - quotes = quotes " " - line = substr(line, 2) - } - } - if (level == 1) { - color = quote_1 - } else if (level == 2) { - color = quote_2 - } else if (level == 3) { - color = quote_3 - } else if (level == 4) { - color = quote_4 - } else { - color = quote_x - } - if (line ~ /^\+/) { - return color quotes diff_add line reset - } else if (line ~ /^-/) { - return color quotes diff_del line reset - } - gsub(url_pattern, url "&" color, line) - return color quotes line reset -} -{ - # Strip carriage returns from line - sub(/\r$/, "") - - if (in_diff) { - if ($0 ~ /^-- ?$/) { - in_signature = 1 - in_diff = 0 - in_headers = 0 - in_body = 0 - $0 = signature $0 reset - } else if ($0 ~ /^@@ /) { - $0 = diff_chunk $0 reset - } else if ($0 ~ /^(diff --git|index|---|\+\+\+) /) { - $0 = diff_meta $0 reset - } else if ($0 ~ /^\+/) { - $0 = diff_add $0 reset - } else if ($0 ~ /^-/) { - $0 = diff_del $0 reset - } - } else if (in_signature) { - gsub(url_pattern, url "&" signature) - $0 = signature $0 reset - } else if (in_headers) { - if ($0 ~ /^$/) { - in_signature = 0 - in_diff = 0 - in_headers = 0 - in_body = 1 - } else { - sub(header_pattern, header "&" reset) - gsub(url_pattern, url "&" reset) - } - } else if (in_body) { - if ($0 ~ /^>/) { - $0 = color_quote($0) - } else if ($0 ~ /^diff --git /) { - in_signature = 0 - in_diff = 1 - in_headers = 0 - in_body = 0 - $0 = diff_meta $0 reset - } else if ($0 ~ /^-- ?$/) { - in_signature = 1 - in_diff = 0 - in_headers = 0 - in_body = 0 - $0 = signature $0 reset - } else { - gsub(url_pattern, url "&" reset) - } - } else if ($0 ~ /^diff --git /) { - in_signature = 0 - in_diff = 1 - in_headers = 0 - in_body = 0 - $0 = diff_meta $0 reset - } else if ($0 ~ /^-- ?$/) { - in_signature = 1 - in_diff = 0 - in_headers = 0 - in_body = 0 - $0 = signature $0 reset - } else if ($0 ~ header_pattern) { - in_signature = 0 - in_diff = 0 - in_headers = 1 - in_body = 0 - sub(header_pattern, header "&" reset) - gsub(url_pattern, url "&" reset) - } else { - in_signature = 0 - in_diff = 0 - in_headers = 0 - in_body = 1 - if ($0 ~ /^>/) { - $0 = color_quote($0) - } else { - gsub(url_pattern, url "&" reset) - } - } - - print -} diff --git a/users/simon/modules/mail/aerc/default.nix b/users/simon/modules/mail/aerc/default.nix deleted file mode 100644 index 7f61919..0000000 --- a/users/simon/modules/mail/aerc/default.nix +++ /dev/null @@ -1,303 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - options = { - accounts.email.accounts = lib.mkOption { - type = lib.types.attrsOf (lib.types.submodule { - options.aerc-sbruder.enable = lib.mkEnableOption "aerc (custom implementation)"; - }); - }; - }; - config = { - programs.aerc = { - enable = true; - - # incomplete support for all configuration options! - extraAccounts = - (lib.mapAttrs - (name: accountConfig: with accountConfig; let - quoteMailAddress = lib.replaceStrings [ "@" "\\" ] [ "%40" "%5C" ]; - # home-manager has no way to set if an account requires AUTH LOGIN - # this emulats this by setting a list of known providers that do require it - requiresLogin = lib.elem - (lib.elemAt (lib.strings.splitString "@" address) 1) - [ "mailbox.tu-dresden.de" ]; - in - { - source = - if notmuch.enable - then "notmuch://${config.accounts.email.maildirBasePath}" - else "`imap://${quoteMailAddress userName}@${imap.host}`"; - source-cred-cmd = "`${lib.concatStringsSep " " passwordCommand}`"; - # TODO: remove when copy-to is implemented in aerc for notmuch - outgoing = - if notmuch.enable - then "${./msmtp-wrapper} ${name}" - else "`smtp${lib.optionalString requiresLogin "+login"}://${quoteMailAddress userName}@${smtp.host}`"; - outgoing-cred-cmd = "`${lib.concatStringsSep " " passwordCommand}`"; - from = "${realName} <${address}>"; - smtp-starttls = if smtp.tls.useStartTls then "yes" else "no"; - copy-to = "Sent"; - signature-file = toString (pkgs.writeText "signature-${name}" signature.text); - pgp-key-id = gpg.key; - pgp-auto-sign = gpg.signByDefault; - pgp-opportunistic-encrypt = gpg.encryptByDefault; - } // (lib.optionalAttrs notmuch.enable { - query-map = toString (pkgs.writeText "aerc-query-map" '' - Archive=not tag:inbox and not tag:sent - Git=tag:git - INBOX=tag:inbox - Newsletter=tag:newsletter - Sent=tag:sent - Spam=tag:spam - Trash=tag:deleted - eBay Kleinanzeigen=tag:kleinanzeigen - eBay=tag:ebay - ''); - exclude-tags = lib.concatStringsSep "," [ - "archived" - "deleted" - "spam" - ]; - })) - (lib.filterAttrs - (_: config: config.aerc-sbruder.enable) - config.accounts.email.accounts)); - - extraConfig = { - general = { - pgp-provider = "gpg"; # internal does not work - - # Allow world-readable accounts.conf (passwords are not stored in it, so it is ok) - unsafe-accounts-conf = true; - }; - - ui = { - index-format = "%-17.17D %-20.20n %Z %-20.20g %s"; - - # See https://godoc.org/time#Time.Format - timestamp-format = "2006-01-02 15:04 MST"; - this-day-time-format = "15:04"; - this-week-time-format = "Monday 15:04"; - this-year-time-format = "02 January"; - - pinned-tab-marker = "車"; - - border-char-vertical = "│"; - border-char-horizontal = "─"; - - fuzzy-complete = true; - - #threading-enabled = true; # broken - - new-message-bell = false; - }; - - statusline = { - display-mode = "icon"; - }; - - viewer = { - header-layout = lib.concatStringsSep "," [ - "From|To" - "Cc|Bcc" - "Subject" - "Date" - "Reply-To" - "X-Mailer" - "User-Agent" - ]; - }; - - compose = { - editor = "nvim"; - - header-layout = lib.concatStringsSep "," [ - "To|From" - "Subject" - ]; - - address-book-cmd = "khard email --parsable --remove-first-line %s"; - }; - - filters = { - "subject,~^\\[PATCH" = "awk -f ${pkgs.aerc}/share/aerc/filters/hldiff"; - "text/plain" = "${./colorize}"; # taken from upstream and patched - "text/html" = "html"; # internal filter - "text/calendar" = "${pkgs.python3.withPackages (ps: with ps; [ vobject ])}/bin/python ${pkgs.aerc}/share/aerc/filters/show-ics-details.py"; # hacky fix for broken nix support - }; - - triggers = { - new-email = "exec notify-send -i mail-unread-symbolic 'New e-mail from %n' '%s'"; - }; - - templates = { }; - }; - - extraBinds = { - global = { - # 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 - "" = ":prev-tab"; - "" = ":next-tab"; - "" = ":term"; - }; - - messages = { - "q" = ":quit"; - - "" = ":exec notmuch new"; - - "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"; - "V" = ":mark -v"; - - "T" = ":toggle-threads"; - - "" = ":view"; - #"d" = ":prompt 'Really delete this message?' ':modify-labels +deleted'"; # does not work - "D" = ":modify-labels +deleted -inbox"; - "A" = ":modify-labels -inbox"; - - "ms" = ":modify-labels +spam -inbox"; - "mS" = ":modify-labels -spam +inbox"; - "mn" = ":modify-labels +newsletter"; - "mN" = ":modify-labels -newsletter"; - - "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"; - }; - - view = { - "/" = ":toggle-key-passthrough/"; - "q" = ":close"; - "O" = ":open"; - "S" = ":save"; - "|" = ":pipe"; - "D" = ":modify-labels +deleted -inbox"; - "A" = ":modify-labels -inbox"; - - "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"; - }; - - # Keybindings used when the embedded terminal is not selected in the compose view" - compose = { - "$ex" = ""; - "" = ":prev-field"; - "" = ":next-field"; - "" = ":next-field"; - "" = ":prev-field"; - }; - - # Keybindings used when the embedded terminal is selected in the compose view - "compose::editor" = { - "$noinherit" = "true"; - "$ex" = ""; - "" = ":prev-field"; - "" = ":next-field"; - "" = ":prev-tab"; - "" = ":next-tab"; - }; - - # Keybindings used when reviewing a message to be sent - "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"; - }; - }; - - stylesets = { - default = { - "*.selected.reverse" = true; - - "title.reverse" = true; - "header.bold" = true; - - "*error.bold" = true; - "error.fg" = 1; - "warning.fg" = 3; - "success.fg" = 2; - - "statusline_default.bg" = 0; - "statusline_error.fg" = 1; - "statusline_error.reverse" = true; - "statusline_success.fg" = 2; - "statusline_success.reverse" = true; - - "msglist_unread.bold" = true; - "msglist_deleted.fg" = 10; - - "tab.bg" = 11; - "tab.selected.reverse" = false; - "tab.selected.bg" = 12; - "tab.fg" = 0; - - "completion_default.bg" = 0; - }; - }; - }; - }; -} diff --git a/users/simon/modules/mail/aerc/msmtp-wrapper b/users/simon/modules/mail/aerc/msmtp-wrapper deleted file mode 100755 index ecb3b1b..0000000 --- a/users/simon/modules/mail/aerc/msmtp-wrapper +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# Based on https://paste.sr.ht/~nihil/3a930baa56efba7d56fe03833386ba8b27a23989 -# Originally by Samuel Fadel -# For a discussion, see -# https://lists.sr.ht/~rjarry/aerc-devel/%3C93983e01d0226c34394702886ca748b9cca6a046.camel%40posteo.de%3E -set -euo pipefail - -EMAIL="$(mktemp -u --suffix=.eml)" -clean_email() { - rm -f "$EMAIL" -} - -account="$1" -shift - -# of script gets the email, we save temporarily for using it twice -# ensure clean_email() is called when we exit abnormally -trap 'clean_email' 0 1 2 3 15 -cat > "$EMAIL" - -# assumes all maildir accounts are configured with a 'Sent' directory -# make sure to tag it correctly -notmuch insert --folder="$account/Sent" -inbox -unread +sent < "$EMAIL" -# assumes all accounts are configured with the same name as dir name above in msmtprc -# msmtp could be called with args from aerc, but --read-recipients already does the job -msmtp --account="$account" --read-recipients --read-envelope-from < "$EMAIL" diff --git a/users/simon/modules/mail/default.nix b/users/simon/modules/mail/default.nix index 2685ece..e25c466 100644 --- a/users/simon/modules/mail/default.nix +++ b/users/simon/modules/mail/default.nix @@ -1,11 +1,5 @@ { lib, nixosConfig, pkgs, ... }: { - imports = [ - #./accounts.nix - #./aerc - #./notmuch.nix - ]; - home.packages = with pkgs; lib.optionals nixosConfig.sbruder.gui.enable [ thunderbird ]; diff --git a/users/simon/modules/mail/notmuch.nix b/users/simon/modules/mail/notmuch.nix deleted file mode 100644 index 3e735ab..0000000 --- a/users/simon/modules/mail/notmuch.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - programs.mbsync.enable = true; - # TODO: remove when copy-to is implemented in aerc for notmuch - programs.msmtp.enable = true; - programs.notmuch = { - enable = true; - hooks = { - preNew = '' - mbsync --all - ''; - postNew = '' - notmuch tag +sent -inbox -unread "folder:personal/Sent" - - notmuch tag +ebay "to:ebay@sbruder.de" - notmuch tag +kleinanzeigen "to:ebay-kleinanzeigen@sbruder.de" - notmuch tag +git "from:{.*@github.com or .*@gitlab.com or (no-reply+)?gitea@sbruder.de} or subject:[PATCH]" - notmuch tag +newsletter "subject:newsletter and tag:unread" - ''; - }; - }; -}