From faac1801489baa754785b8173237cdc3f040b24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Thu, 7 Oct 2021 00:43:44 +0200 Subject: [PATCH] feat: bye bye notmuch, hello neomutt --- configs/default.nix | 2 +- configs/neomutt.nix | 247 +++++++++++++++++++++++++++++++ lib/i3status-rust.nix | 11 -- systems/zaatar/configuration.nix | 1 - 4 files changed, 248 insertions(+), 13 deletions(-) create mode 100644 configs/neomutt.nix diff --git a/configs/default.nix b/configs/default.nix index e58f476..ed9a2ef 100644 --- a/configs/default.nix +++ b/configs/default.nix @@ -218,11 +218,11 @@ in { ./keybase.nix ./keyboard.nix ./lb.nix - ./mail/client.nix ./mpv.nix ./mime.nix ./nano.nix ./neovim.nix + ./neomutt.nix ./nix.nix ./newsboat.nix ./flameshot-once.nix diff --git a/configs/neomutt.nix b/configs/neomutt.nix new file mode 100644 index 0000000..2b4fe39 --- /dev/null +++ b/configs/neomutt.nix @@ -0,0 +1,247 @@ +{ pkgs, lib, ... }: +let + accounts.meinhark = { + user = "meinhark"; + password = lib.strings.fileContents ; + address = "kieran.felix.meinhardt@hu-berlin.de"; + imap = "mailbox.cms.hu-berlin.de"; + smtp = "mailhost.cms.hu-berlin.de"; + smtpSettings = smtp: "smtp://${smtp}"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + accounts.meinhaki = { + user = "meinhaki"; + password = lib.strings.fileContents ; + address = "kieran.meinhardt@hu-berlin.de"; + imap = "mailbox.cms.hu-berlin.de"; + smtp = "mailhost.cms.hu-berlin.de"; + smtpSettings = smtp: "smtp://${smtp}"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + accounts.fysi = rec { + user = "kieran@fysi.tech"; + address = user; + password = lib.strings.fileContents ; + imap = "imap.fastmail.com"; + smtp = "smtp.fastmail.com"; + smtpSettings = smtp: "smtps://${smtp}:465"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + accounts.cock = rec { + user = "2210@cock.li"; + address = user; + password = lib.strings.fileContents ; + imap = "mail.cock.li"; + smtp = imap; + smtpSettings = smtp: "smtp://${smtp}:587"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + accounts.posteo = rec { + user = "kieran.meinhardt@posteo.net"; + address = user; + password = lib.strings.fileContents ; + imap = "posteo.de"; + smtp = imap; + smtpSettings = smtp: "smtp://${smtp}"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + accounts.amroplay = rec { + user = "amroplay@gmail.com"; + address = user; + password = lib.strings.fileContents ; + imap = "imap.gmail.com"; + smtp = "smtp.gmail.com"; + smtpSettings = smtp: "smtps://${smtp}:465"; + folders = { + drafts = "[Gmail]/Drafts"; + sent = "[Gmail]/Sent Mail"; + trash = "[Gmail]/Bin"; + }; + }; + + accounts.kieran-gmail = rec { + user = "kieran.meinhardt@gmail.com"; + address = user; + password = lib.strings.fileContents ; + imap = "imap.gmail.com"; + smtp = "smtp.gmail.com"; + smtpSettings = smtp: "smtps://${smtp}:465"; + folders = { + drafts = "[Gmail]/Entwürfe"; + sent = "[Gmail]/Gesendet"; + trash = "[Gmail]/Papierkorb"; + }; + }; +in +{ + environment.systemPackages = [ pkgs.neomutt ]; + + home-manager.users.me.xdg.configFile."neomutt/neomuttrc".text = '' + set mailcap_path = ${pkgs.writeText "mailcap" '' + text/plain; $EDITOR %s ; + text/html; ${pkgs.lynx}/bin/lynx -assume_charset=%{charset} -display_charset=utf-8 -dump %s; nametemplate=%s.html; copiousoutput; + image/*; ${pkgs.sxiv}/bin/sxiv %s ; + video/*; ${pkgs.utillinux}/bin/setsid ${pkgs.mpv}/bin/mpv --quiet %s &; copiousoutput + audio/*; ${pkgs.mpv}/bin/mpv %s ; + application/pdf; ${pkgs.zathura}/bin/zathura %s ; + application/pgp-encrypted; ${pkgs.gnupg}/bin/gpg -d '%s'; copiousoutput; + application/pgp-keys; ${pkgs.gnupg}/bin/gpg --import '%s'; copiousoutput; + ''}:$mailcap_path + + set sidebar_visible + set sidebar_format = "%D%?F? [%F]?%* %?N?%N/?%S" + set sidebar_width = 25 # Plenty of space + set sidebar_divider_char = '│' # Pretty line-drawing character + set mail_check_stats + + set index_format="%2C %Z %D %-15.15L %s" + set date_format="%F %R" + + set sort = 'reverse-date' + set sleep_time = 0 # Pause 0 seconds for informational messages + set markers = no # Disables the `+` displayed at line wraps + set mark_old = no # Unread mail stay unread until read + set mime_forward = yes # attachments are forwarded with mail + set wait_key = no # mutt won't ask "press key to continue" + set fast_reply # skip to compose when replying + set forward_format = "Fwd: %s" # format of subject when forwarding + set forward_quote # include message in forwards + set reverse_name # reply as whomever it was to + set include=ask-no # don't include message in replies + auto_view text/html # automatically show html (mailcap uses lynx) + auto_view application/pgp-encrypted + alternative_order text/plain text/enriched text/html + + set abort_noattach abort_noattach_regex="\<(attach|attached|attachments?|Anhang|angehängt)\>" + set attach_save_dir=/tmp + set fast_reply + + set narrow_tree # narrow threads for more depth + + bind index,pager B sidebar-toggle-visible # Use 'B' to switch the Sidebar on and off + bind index,pager \Ck sidebar-prev + bind index,pager \Cj sidebar-next + bind index,pager \Co sidebar-open + bind index,pager \Cp sidebar-prev-new + bind index,pager \Cn sidebar-next-new + + set query_command = "khard email --parsable %s" + bind editor complete-query + bind editor ^T complete + + set mail_check = 90 + set timeout = 15 + # set imap_check_subscribed + set use_from + + set spoolfile="+INBOX" + + set header_cache="~/.cache/mutt" message_cachedir="~/.cache/mutt" + + source ${pkgs.writeText "accounts.neomuttrc" '' + set realname = "Kierán Meinhardt" + account-hook . 'unset imap_user imap_pass smtp_user smtp_pass' + # set accordingly: postponed trash record + ${lib.concatStringsSep "\n\n" (lib.mapAttrsToList (name: account: let imapRoot = "imaps://${account.user}@${account.imap}"; in '' + account-hook ${account.user}@${account.imap} 'set imap_user="${account.user}" imap_pass="${account.password}"' + account-hook ${account.user}@${account.smtp} 'set smtp_user="${account.user}" smtp_pass="${account.password}"' + folder-hook ${account.user}@${account.imap} 'set smtp_url="${account.smtpSettings "${account.user}@${account.smtp}"}" from="${account.address}" record="${imapRoot}/${account.folders.sent}" postponed="${imapRoot}/${account.folders.drafts}" trash="${imapRoot}/${account.folders.trash}"' + named-mailboxes "${name}" ${imapRoot} ${ + lib.concatStringsSep " " + (lib.mapAttrsToList + (folder: imapFolder: ''"${name}.${folder}" "${imapRoot}/${imapFolder}"'') + account.folders) + } + '') accounts)} + ''} + + source ${pkgs.writeText "colors.neomuttrc" '' + # Default index colors: + # color index yellow default '.*' + color index_author red default '.*' + color index_number blue default + color index_subject cyan default '.*' + + # New mail is boldened: + # color index brightyellow black "~N" + color index_author brightred black "~N" + color index_subject brightcyan black "~N" + + # Tagged mail is highlighted: + color index brightyellow blue "~T" + color index_author brightred blue "~T" + color index_subject brightcyan blue "~T" + + # Other colors and aesthetic settings: + mono bold bold + mono underline underline + mono indicator reverse + mono error bold + color normal default default + # color indicator brightblack white + # color sidebar_highlight red default + # color sidebar_divider brightblack black + # color sidebar_flagged red black + color sidebar_new red black + # color normal brightyellow default + color error red default + color tilde black default + color message cyan default + color markers red white + color attachment white default + color search brightmagenta default + # color status brightyellow black + color hdrdefault brightgreen default + color quoted green default + color quoted1 blue default + color quoted2 cyan default + color quoted3 yellow default + color quoted4 red default + color quoted5 brightred default + color signature brightgreen default + color bold black default + color underline black default + color normal default default + + # Regex highlighting: + color header blue default ".*" + color header brightmagenta default "^(From)" + color header brightcyan default "^(Subject)" + color header brightwhite default "^(CC|BCC)" + color body brightred default "[\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+" # Email addresses + color body brightblue default "(https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+" # URL + color body yellow default "^(\t| )*(-|\\*) \.*" # List items as yellow + color body red default "(BAD signature)|^gpg: BAD signature from.*" + color body brightgreen default "(Good signature)|^gpg: Good signature .*" + color body brightyellow default "^gpg: " + mono body bold "^gpg: Good signature" + mono body bold "^gpg: BAD signature from.*" + color body red default "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]" + ''} + ''; +} diff --git a/lib/i3status-rust.nix b/lib/i3status-rust.nix index 3a88130..62f7441 100644 --- a/lib/i3status-rust.nix +++ b/lib/i3status-rust.nix @@ -100,17 +100,6 @@ in { | ${pkgs.jq}/bin/jq -r '"💉 Ⅰ \(.data.quote * 1000 | floor | . / 10)% Ⅱ \(.data.secondVaccination.quote * 1000 | floor | . / 10)%"' ''; } - { - block = "custom"; - interval = 30; - command = - let query = "tag:unread AND tag:inbox"; - in pkgs.writers.writeDash "count-new-mail" '' - mail_count="$(${pkgs.notmuch}/bin/notmuch search ${lib.escapeShellArg query} | wc -l)" - [ "$mail_count" = 0 ] && printf "📭" || printf "📬" - echo "$mail_count" - ''; - } (let service = "openvpn-hu-berlin"; in { block = "custom"; interval = 5; diff --git a/systems/zaatar/configuration.nix b/systems/zaatar/configuration.nix index 2e23cf6..dceec4f 100644 --- a/systems/zaatar/configuration.nix +++ b/systems/zaatar/configuration.nix @@ -14,7 +14,6 @@ - { nixpkgs.config.allowUnfree = true; }