This repository has no description
0

Configure Feed

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

1{ 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 = [ 73 "to:gmail@lassul.us" 74 "to:lassulus@gmail.com" 75 "lassulus@googlemail.com" 76 ]; 77 india = [ 78 "to:hillhackers@lists.hillhacks.in" 79 "to:hackbeach@lists.hackbeach.in" 80 "to:hackbeach@mail.hackbeach.in" 81 ]; 82 kaosstuff = [ 83 "to:gearbest@lassul.us" 84 "to:banggood@lassul.us" 85 "to:tomtop@lassul.us" 86 ]; 87 lugs = [ "to:lugs@lug-s.org" ]; 88 meetup = [ "to:meetup@lassul.us" ]; 89 nix = [ 90 "to:nix-devel@googlegroups.com" 91 "to:nix@lassul.us" 92 ]; 93 patreon = [ "to:patreon@lassul.us" ]; 94 paypal = [ "to:paypal@lassul.us" ]; 95 ptl = [ "to:ptl@posttenebraslab.ch" ]; 96 retiolum = [ "to:lass@mors.r" ]; 97 security = [ 98 "to:seclists.org" 99 "to:bugtraq" 100 "to:securityfocus@lassul.us" 101 "to:security-announce@lists.apple.com" 102 ]; 103 shack = [ "to:shackspace.de" ]; 104 steam = [ "to:steam@lassul.us" ]; 105 tinc = [ 106 "to:tinc@tinc-vpn.org" 107 "to:tinc-devel@tinc-vpn.org" 108 ]; 109 wireguard = [ "to:wireguard@lists.zx2c4" ]; 110 zzz = [ 111 "to:pizza@lassul.us" 112 "to:spam@krebsco.de" 113 ]; 114 }; 115 116 tag-new-mails = pkgs.writeDashBin "nm-tag-init" '' 117 ${pkgs.notmuch}/bin/notmuch new 118 ${lib.concatMapStringsSep "\n" (i: '' 119 mkdir -p "$HOME/Maildir/.${i.name}/cur" 120 for mail in $(${pkgs.notmuch}/bin/notmuch search --output=files 'tag:inbox and (${ 121 lib.concatMapStringsSep " or " (f: "${f}") i.value 122 })'); do 123 if test -e "$mail"; then 124 mv "$mail" "$HOME/Maildir/.${i.name}/cur/" 125 else 126 echo "$mail does not exist" 127 fi 128 done 129 ${pkgs.notmuch}/bin/notmuch tag -inbox +${i.name} -- tag:inbox ${ 130 lib.concatMapStringsSep " or " (f: "${f}") i.value 131 } 132 '') (lib.mapAttrsToList lib.nameValuePair mailboxes)} 133 ${pkgs.notmuch}/bin/notmuch new 134 ${pkgs.notmuch}/bin/notmuch dump > "$HOME/Maildir/notmuch.backup" 135 ''; 136 137 tag-old-mails = pkgs.writeDashBin "nm-tag-old" '' 138 set -efux 139 ${lib.concatMapStringsSep "\n" (i: '' 140 ${pkgs.notmuch}/bin/notmuch tag -inbox -archive +${i.name} -- ${ 141 lib.concatMapStringsSep " or " (f: "${f}") i.value 142 } 143 mkdir -p "$HOME/Maildir/.${i.name}/cur" 144 for mail in $(${pkgs.notmuch}/bin/notmuch search --output=files ${ 145 lib.concatMapStringsSep " or " (f: "${f}") i.value 146 }); do 147 if test -e "$mail"; then 148 mv "$mail" "$HOME/Maildir/.${i.name}/cur/" 149 else 150 echo "$mail does not exist" 151 fi 152 done 153 '') (lib.mapAttrsToList lib.nameValuePair mailboxes)} 154 ${pkgs.notmuch}/bin/notmuch new --no-hooks 155 ''; 156 157 muttrc = pkgs.writeText "muttrc" '' 158 159 # read html mails 160 auto_view text/html 161 set mailcap_path = ${mailcap} 162 163 # notmuch 164 set folder="$HOME/Maildir" 165 set nm_default_uri = "notmuch://$HOME/Maildir" 166 set nm_record = yes 167 set nm_record_tags = "-inbox me archive" 168 set spoolfile = +Inbox 169 set virtual_spoolfile = yes 170 171 172 set sendmail="${msmtp}/bin/msmtp" # enables parsing of outgoing mail 173 set from="lassulus@lassul.us" 174 alternates ^.*@lassul\.us$ ^.*@.*\.r$ 175 unset envelope_from_address 176 set use_envelope_from 177 set reverse_name 178 set markers=no 179 180 set sort=threads 181 182 set index_format="%4C %Z %?GI?%GI& ? %[%y-%m-%d] %-20.20a %?M?(%3M)& ? %s %> %r %g" 183 184 virtual-mailboxes "Unread" "notmuch://?query=tag:unread" 185 virtual-mailboxes "INBOX" "notmuch://?query=tag:inbox" 186 ${lib.concatMapStringsSep "\n" ( 187 i: ''${" "}virtual-mailboxes "${i.name}" "notmuch://?query=tag:${i.name}"'' 188 ) (lib.mapAttrsToList lib.nameValuePair mailboxes)} 189 virtual-mailboxes "TODO" "notmuch://?query=tag:TODO" 190 virtual-mailboxes "Starred" "notmuch://?query=tag:*" 191 virtual-mailboxes "Archive" "notmuch://?query=tag:archive" 192 virtual-mailboxes "Sent" "notmuch://?query=tag:sent" 193 virtual-mailboxes "Junk" "notmuch://?query=tag:junk" 194 virtual-mailboxes "All" "notmuch://?query=*" 195 196 tag-transforms "junk" "k" \ 197 "unread" "u" \ 198 "replied" "↻" \ 199 "TODO" "T" \ 200 201 # notmuch bindings 202 macro index \\\\ "<vfolder-from-query>" # looks up a hand made query 203 macro index + "<modify-labels>+*\n<sync-mailbox>" # tag as starred 204 macro index - "<modify-labels>-*\n<sync-mailbox>" # tag as unstarred 205 206 # muchsync 207 bind index \Cr noop 208 macro index \Cr \ 209 "<enter-command>unset wait_key<enter> \ 210 <shell-escape>mailsync<enter> 211 212 #killed 213 bind index d noop 214 bind pager d noop 215 216 bind index S noop 217 bind index s noop 218 bind pager S noop 219 bind pager s noop 220 macro index S "<modify-labels-then-hide>-inbox -unread +junk\n" # tag as Junk mail 221 macro index s "<modify-labels>-junk\n" # tag as Junk mail 222 macro pager S "<modify-labels-then-hide>-inbox -unread +junk\n" # tag as Junk mail 223 macro pager s "<modify-labels>-junk\n" # tag as Junk mail 224 225 226 bind index A noop 227 bind index a noop 228 bind pager A noop 229 bind pager a noop 230 macro index A "<modify-labels>+archive -unread -inbox\n" # tag as Archived 231 macro index a "<modify-labels>-archive\n" # tag as Archived 232 macro pager A "<modify-labels>+archive -unread -inbox\n" # tag as Archived 233 macro pager a "<modify-labels>-archive\n" # tag as Archived 234 235 236 bind index U noop 237 bind index u noop 238 bind pager U noop 239 bind pager u noop 240 macro index U "<modify-labels>+unread\n" 241 macro index u "<modify-labels>-unread\n" 242 macro pager U "<modify-labels>+unread\n" 243 macro pager u "<modify-labels>-unread\n" 244 245 246 bind index t noop 247 bind pager t noop 248 macro index t "<modify-labels>" # tag as Archived 249 250 # top index bar in email view 251 set pager_index_lines=7 252 # top_index_bar toggle 253 macro pager ,@1 "<enter-command> set pager_index_lines=0; macro pager ] ,@2 'Toggle indexbar<Enter>" 254 macro pager ,@2 "<enter-command> set pager_index_lines=3; macro pager ] ,@3 'Toggle indexbar<Enter>" 255 macro pager ,@3 "<enter-command> set pager_index_lines=7; macro pager ] ,@1 'Toggle indexbar<Enter>" 256 macro pager ] ,@1 'Toggle indexbar 257 258 259 # scan urls from emails 260 macro index,pager \cb "<pipe-message> ${lib.getExe pkgs.urlscan}<Enter>" "call urlscan to extract URLs out of a message" 261 macro attach,compose \cb "<pipe-entry> ${lib.getExe pkgs.urlscan}<Enter>" "call urlscan to extract URLs out of a message" 262 263 # sidebar 264 set sidebar_divider_char = '│' 265 set sidebar_delim_chars = "/" 266 set sidebar_short_path 267 set sidebar_folder_indent 268 set sidebar_visible = yes 269 set sidebar_format = '%D%?F? [%F]?%* %?N?%N/? %?S?%S?' 270 set sidebar_width = 20 271 color sidebar_new yellow red 272 273 # sidebar bindings 274 bind index <left> sidebar-prev # got to previous folder in sidebar 275 bind index <right> sidebar-next # got to next folder in sidebar 276 bind index <space> sidebar-open # open selected folder from sidebar 277 # sidebar toggle 278 macro index,pager ,@) "<enter-command> set sidebar_visible=no; macro index,pager [ ,@( 'Toggle sidebar'<Enter>" 279 macro index,pager ,@( "<enter-command> set sidebar_visible=yes; macro index,pager [ ,@) 'Toggle sidebar'<Enter>" 280 macro index,pager [ ,@( 'Toggle sidebar' # toggle the sidebar 281 282 # forward with attachment 283 # https://github.com/neomutt/neomutt/issues/1258#issuecomment-689522156 284 set mime_forward = no 285 set forward_attachments = yes 286 ''; 287 288 mutt = pkgs.symlinkJoin { 289 name = "mutt"; 290 paths = [ 291 (pkgs.writeDashBin "mutt" '' 292 exec ${pkgs.neomutt}/bin/neomutt -F ${muttrc} "$@" 293 '') 294 pkgs.neomutt 295 ]; 296 }; 297 298in 299{ 300 environment.variables.NOTMUCH_CONFIG = toString notmuch-config; 301 environment.systemPackages = [ 302 msmtp 303 mutt 304 pkgs.notmuch 305 pkgs.muchsync 306 tag-new-mails 307 tag-old-mails 308 (pkgs.writeShellApplication { 309 name = "mailsync"; 310 meta.description = "sync mails with muchsync with green"; 311 runtimeInputs = [ pkgs.muchsync ]; 312 text = '' 313 if ping -W2 -c1 green.s; then 314 muchsync lass@green.s 315 elif ping -W2 -c1 green.n; then 316 muchsync lass@green.n 317 elif ping -W2 -c1 green.r; then 318 muchsync lass@green.r 319 else 320 echo no green host reachable 321 exit 1 322 fi 323 ''; 324 }) 325 ]; 326}