This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / 2configs / mail.nix
9.2 kB 272 lines
1{ config, lib, pkgs, ... }: 2 3let 4 5 msmtprc = pkgs.writeText "msmtprc" '' 6 defaults 7 logfile ~/.msmtp.log 8 account prism 9 host prism.r 10 account c-base 11 from lassulus@c-base.org 12 host c-mail.c-base.org 13 port 465 14 tls on 15 tls_starttls off 16 auth on 17 user lassulus 18 passwordeval pass show c-base/pass 19 account default: prism 20 ''; 21 22 notmuch-config = pkgs.writeText "notmuch-config" '' 23 [database] 24 path=/home/lass/Maildir 25 mail_root=/home/lass/Maildir 26 27 [user] 28 name=lassulus 29 primary_email=lassulus@lassul.us 30 other_email=lass@mors.r;${lib.concatStringsSep ";" (lib.flatten (lib.attrValues mailboxes))} 31 32 [new] 33 tags=unread;inbox; 34 ignore= 35 36 [search] 37 exclude_tags=deleted;spam; 38 39 [maildir] 40 synchronize_flags=true 41 ''; 42 43 msmtp = pkgs.writeBashBin "msmtp" '' 44 ${pkgs.coreutils}/bin/tee >(${pkgs.notmuch}/bin/notmuch insert +sent) | \ 45 ${pkgs.msmtp}/bin/msmtp -C ${msmtprc} "$@" 46 ''; 47 48 mailcap = pkgs.writeText "mailcap" '' 49 text/html; ${pkgs.elinks}/bin/elinks -dump ; copiousoutput; 50 ''; 51 52 mailboxes = { 53 afra = [ "to:afra@afra-berlin.de" ]; 54 c-base = [ "to:c-base.org" ]; 55 coins = [ 56 "to:btce@lassul.us" 57 "to:coinbase@lassul.us" 58 "to:polo@lassul.us" 59 "to:bitwala@lassul.us" 60 "to:payeer@lassul.us" 61 "to:gatehub@lassul.us" 62 "to:bitfinex@lassul.us" 63 "to:binance@lassul.us" 64 "to:bitcoin.de@lassul.us" 65 "to:robinhood@lassul.us" 66 ]; 67 dezentrale = [ "to:dezentrale.space" ]; 68 dhl = [ "to:dhl@lassul.us" ]; 69 dn42 = [ "to:dn42@lists.nox.tf" ]; 70 eloop = [ "to:eloop.org" ]; 71 github = [ "to:github@lassul.us" ]; 72 gmail = [ "to:gmail@lassul.us" "to:lassulus@gmail.com" "lassulus@googlemail.com" ]; 73 india = [ "to:hillhackers@lists.hillhacks.in" "to:hackbeach@lists.hackbeach.in" "to:hackbeach@mail.hackbeach.in" ]; 74 kaosstuff = [ "to:gearbest@lassul.us" "to:banggood@lassul.us" "to:tomtop@lassul.us" ]; 75 lugs = [ "to:lugs@lug-s.org" ]; 76 meetup = [ "to:meetup@lassul.us" ]; 77 nix = [ "to:nix-devel@googlegroups.com" "to:nix@lassul.us" ]; 78 patreon = [ "to:patreon@lassul.us" ]; 79 paypal = [ "to:paypal@lassul.us" ]; 80 ptl = [ "to:ptl@posttenebraslab.ch" ]; 81 retiolum = [ "to:lass@mors.r" ]; 82 security = [ 83 "to:seclists.org" "to:bugtraq" "to:securityfocus@lassul.us" 84 "to:security-announce@lists.apple.com" 85 ]; 86 shack = [ "to:shackspace.de" ]; 87 steam = [ "to:steam@lassul.us" ]; 88 tinc = [ "to:tinc@tinc-vpn.org" "to:tinc-devel@tinc-vpn.org" ]; 89 wireguard = [ "to:wireguard@lists.zx2c4" ]; 90 zzz = [ "to:pizza@lassul.us" "to:spam@krebsco.de" ]; 91 }; 92 93 tag-new-mails = pkgs.writeDashBin "nm-tag-init" '' 94 ${pkgs.notmuch}/bin/notmuch new 95 ${lib.concatMapStringsSep "\n" (i: '' 96 mkdir -p "$HOME/Maildir/.${i.name}/cur" 97 for mail in $(${pkgs.notmuch}/bin/notmuch search --output=files 'tag:inbox and (${lib.concatMapStringsSep " or " (f: "${f}") i.value})'); do 98 if test -e "$mail"; then 99 mv "$mail" "$HOME/Maildir/.${i.name}/cur/" 100 else 101 echo "$mail does not exist" 102 fi 103 done 104 ${pkgs.notmuch}/bin/notmuch tag -inbox +${i.name} -- tag:inbox ${lib.concatMapStringsSep " or " (f: "${f}") i.value} 105 '') (lib.mapAttrsToList lib.nameValuePair mailboxes)} 106 ${pkgs.notmuch}/bin/notmuch new 107 ${pkgs.notmuch}/bin/notmuch dump > "$HOME/Maildir/notmuch.backup" 108 ''; 109 110 tag-old-mails = pkgs.writeDashBin "nm-tag-old" '' 111 set -efux 112 ${lib.concatMapStringsSep "\n" (i: '' 113 ${pkgs.notmuch}/bin/notmuch tag -inbox -archive +${i.name} -- ${lib.concatMapStringsSep " or " (f: "${f}") i.value} 114 mkdir -p "$HOME/Maildir/.${i.name}/cur" 115 for mail in $(${pkgs.notmuch}/bin/notmuch search --output=files ${lib.concatMapStringsSep " or " (f: "${f}") i.value}); do 116 if test -e "$mail"; then 117 mv "$mail" "$HOME/Maildir/.${i.name}/cur/" 118 else 119 echo "$mail does not exist" 120 fi 121 done 122 '') (lib.mapAttrsToList lib.nameValuePair mailboxes)} 123 ${pkgs.notmuch}/bin/notmuch new --no-hooks 124 ''; 125 126 muttrc = pkgs.writeText "muttrc" '' 127 128 # read html mails 129 auto_view text/html 130 set mailcap_path = ${mailcap} 131 132 # notmuch 133 set folder="$HOME/Maildir" 134 set nm_default_uri = "notmuch://$HOME/Maildir" 135 set nm_record = yes 136 set nm_record_tags = "-inbox me archive" 137 set spoolfile = +Inbox 138 set virtual_spoolfile = yes 139 140 141 set sendmail="${msmtp}/bin/msmtp" # enables parsing of outgoing mail 142 set from="lassulus@lassul.us" 143 alternates ^.*@lassul\.us$ ^.*@.*\.r$ 144 unset envelope_from_address 145 set use_envelope_from 146 set reverse_name 147 148 set sort=threads 149 150 set index_format="%4C %Z %?GI?%GI& ? %[%y-%m-%d] %-20.20a %?M?(%3M)& ? %s %> %r %g" 151 152 virtual-mailboxes "Unread" "notmuch://?query=tag:unread" 153 virtual-mailboxes "INBOX" "notmuch://?query=tag:inbox" 154 ${lib.concatMapStringsSep "\n" (i: ''${" "}virtual-mailboxes "${i.name}" "notmuch://?query=tag:${i.name}"'') (lib.mapAttrsToList lib.nameValuePair mailboxes)} 155 virtual-mailboxes "TODO" "notmuch://?query=tag:TODO" 156 virtual-mailboxes "Starred" "notmuch://?query=tag:*" 157 virtual-mailboxes "Archive" "notmuch://?query=tag:archive" 158 virtual-mailboxes "Sent" "notmuch://?query=tag:sent" 159 virtual-mailboxes "Junk" "notmuch://?query=tag:junk" 160 virtual-mailboxes "All" "notmuch://?query=*" 161 162 tag-transforms "junk" "k" \ 163 "unread" "u" \ 164 "replied" "↻" \ 165 "TODO" "T" \ 166 167 # notmuch bindings 168 macro index \\\\ "<vfolder-from-query>" # looks up a hand made query 169 macro index + "<modify-labels>+*\n<sync-mailbox>" # tag as starred 170 macro index - "<modify-labels>-*\n<sync-mailbox>" # tag as unstarred 171 172 # muchsync 173 bind index \Cr noop 174 macro index \Cr \ 175 "<enter-command>unset wait_key<enter> \ 176 <shell-escape>${pkgs.writeDash "muchsync" '' 177 set -efu 178 until ${pkgs.muchsync}/bin/muchsync -F lass@green.r; do 179 sleep 1 180 done 181 ''}<enter> 182 183 #killed 184 bind index d noop 185 bind pager d noop 186 187 bind index S noop 188 bind index s noop 189 bind pager S noop 190 bind pager s noop 191 macro index S "<modify-labels-then-hide>-inbox -unread +junk\n" # tag as Junk mail 192 macro index s "<modify-labels>-junk\n" # tag as Junk mail 193 macro pager S "<modify-labels-then-hide>-inbox -unread +junk\n" # tag as Junk mail 194 macro pager s "<modify-labels>-junk\n" # tag as Junk mail 195 196 197 bind index A noop 198 bind index a noop 199 bind pager A noop 200 bind pager a noop 201 macro index A "<modify-labels>+archive -unread -inbox\n" # tag as Archived 202 macro index a "<modify-labels>-archive\n" # tag as Archived 203 macro pager A "<modify-labels>+archive -unread -inbox\n" # tag as Archived 204 macro pager a "<modify-labels>-archive\n" # tag as Archived 205 206 207 bind index U noop 208 bind index u noop 209 bind pager U noop 210 bind pager u noop 211 macro index U "<modify-labels>+unread\n" 212 macro index u "<modify-labels>-unread\n" 213 macro pager U "<modify-labels>+unread\n" 214 macro pager u "<modify-labels>-unread\n" 215 216 217 bind index t noop 218 bind pager t noop 219 macro index t "<modify-labels>" # tag as Archived 220 221 # top index bar in email view 222 set pager_index_lines=7 223 # top_index_bar toggle 224 macro pager ,@1 "<enter-command> set pager_index_lines=0; macro pager ] ,@2 'Toggle indexbar<Enter>" 225 macro pager ,@2 "<enter-command> set pager_index_lines=3; macro pager ] ,@3 'Toggle indexbar<Enter>" 226 macro pager ,@3 "<enter-command> set pager_index_lines=7; macro pager ] ,@1 'Toggle indexbar<Enter>" 227 macro pager ] ,@1 'Toggle indexbar 228 229 # urlview 230 macro pager \cb <pipe-entry>'${pkgs.urlview}/bin/urlview'<enter> 'Follow links with urlview' 231 232 # sidebar 233 set sidebar_divider_char = '│' 234 set sidebar_delim_chars = "/" 235 set sidebar_short_path 236 set sidebar_folder_indent 237 set sidebar_visible = yes 238 set sidebar_format = '%D%?F? [%F]?%* %?N?%N/? %?S?%S?' 239 set sidebar_width = 20 240 color sidebar_new yellow red 241 242 # sidebar bindings 243 bind index <left> sidebar-prev # got to previous folder in sidebar 244 bind index <right> sidebar-next # got to next folder in sidebar 245 bind index <space> sidebar-open # open selected folder from sidebar 246 # sidebar toggle 247 macro index,pager ,@) "<enter-command> set sidebar_visible=no; macro index,pager [ ,@( 'Toggle sidebar'<Enter>" 248 macro index,pager ,@( "<enter-command> set sidebar_visible=yes; macro index,pager [ ,@) 'Toggle sidebar'<Enter>" 249 macro index,pager [ ,@( 'Toggle sidebar' # toggle the sidebar 250 ''; 251 252 mutt = pkgs.symlinkJoin { 253 name = "mutt"; 254 paths = [ 255 (pkgs.writeDashBin "mutt" '' 256 exec ${pkgs.neomutt}/bin/neomutt -F ${muttrc} "$@" 257 '') 258 pkgs.neomutt 259 ]; 260 }; 261 262in { 263 environment.variables.NOTMUCH_CONFIG = toString notmuch-config; 264 environment.systemPackages = [ 265 msmtp 266 mutt 267 pkgs.notmuch 268 pkgs.muchsync 269 tag-new-mails 270 tag-old-mails 271 ]; 272}