This repository has no description
0

Configure Feed

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

tools.mutt: add mail client with full configuration

Add mutt wrapper with msmtp, notmuch, mailcap configuration and
tor fallback for mail sending.

+284
+280
tools/mutt/flake-module.nix
··· 1 + { self, ... }: 2 + { 3 + perSystem = 4 + { pkgs, lib, ... }: 5 + { 6 + packages.mutt = 7 + let 8 + # Mailboxes configuration from mail.nix 9 + mailboxes = { 10 + afra = [ "to:afra@afra-berlin.de" ]; 11 + c-base = [ "to:c-base.org" ]; 12 + coins = [ 13 + "to:btce@lassul.us" 14 + "to:coinbase@lassul.us" 15 + "to:polo@lassul.us" 16 + "to:bitwala@lassul.us" 17 + "to:payeer@lassul.us" 18 + "to:gatehub@lassul.us" 19 + "to:bitfinex@lassul.us" 20 + "to:binance@lassul.us" 21 + "to:bitcoin.de@lassul.us" 22 + "to:robinhood@lassul.us" 23 + ]; 24 + dezentrale = [ "to:dezentrale.space" ]; 25 + dhl = [ "to:dhl@lassul.us" ]; 26 + dn42 = [ "to:dn42@lists.nox.tf" ]; 27 + eloop = [ "to:eloop.org" ]; 28 + github = [ "to:github@lassul.us" ]; 29 + gmail = [ 30 + "to:gmail@lassul.us" 31 + "to:lassulus@gmail.com" 32 + "lassulus@googlemail.com" 33 + ]; 34 + india = [ 35 + "to:hillhackers@lists.hillhacks.in" 36 + "to:hackbeach@lists.hackbeach.in" 37 + "to:hackbeach@mail.hackbeach.in" 38 + ]; 39 + kaosstuff = [ 40 + "to:gearbest@lassul.us" 41 + "to:banggood@lassul.us" 42 + "to:tomtop@lassul.us" 43 + ]; 44 + lugs = [ "to:lugs@lug-s.org" ]; 45 + meetup = [ "to:meetup@lassul.us" ]; 46 + nix = [ 47 + "to:nix-devel@googlegroups.com" 48 + "to:nix@lassul.us" 49 + ]; 50 + patreon = [ "to:patreon@lassul.us" ]; 51 + paypal = [ "to:paypal@lassul.us" ]; 52 + ptl = [ "to:ptl@posttenebraslab.ch" ]; 53 + retiolum = [ "to:lass@mors.r" ]; 54 + security = [ 55 + "to:seclists.org" 56 + "to:bugtraq" 57 + "to:securityfocus@lassul.us" 58 + "to:security-announce@lists.apple.com" 59 + ]; 60 + shack = [ "to:shackspace.de" ]; 61 + steam = [ "to:steam@lassul.us" ]; 62 + tinc = [ 63 + "to:tinc@tinc-vpn.org" 64 + "to:tinc-devel@tinc-vpn.org" 65 + ]; 66 + wireguard = [ "to:wireguard@lists.zx2c4" ]; 67 + zzz = [ 68 + "to:pizza@lassul.us" 69 + "to:spam@krebsco.de" 70 + ]; 71 + }; 72 + 73 + notmuchConfig = '' 74 + [database] 75 + path=Maildir 76 + mail_root=Maildir 77 + 78 + [user] 79 + name=lassulus 80 + primary_email=lassulus@lassul.us 81 + other_email=lass@mors.r;${lib.concatStringsSep ";" (lib.flatten (lib.attrValues mailboxes))} 82 + 83 + [new] 84 + tags=unread;inbox; 85 + ignore= 86 + 87 + [search] 88 + exclude_tags=deleted;spam; 89 + 90 + [maildir] 91 + synchronize_flags=true 92 + ''; 93 + 94 + mailcap = pkgs.writeText "mailcap" '' 95 + text/html; ${pkgs.elinks}/bin/elinks -dump ; copiousoutput; 96 + ''; 97 + 98 + msmtprc = pkgs.writeText "msmtprc" '' 99 + defaults 100 + logfile ~/.msmtp.log 101 + account prism 102 + host prism.r 103 + account c-base 104 + from lassulus@c-base.org 105 + host c-mail.c-base.org 106 + port 465 107 + tls on 108 + tls_starttls off 109 + auth on 110 + user lassulus 111 + passwordeval pass show c-base/pass 112 + account default: prism 113 + ''; 114 + 115 + msmtp = pkgs.writeBashBin "msmtp" '' 116 + # Check if prism.r is reachable, fallback to Tor if not 117 + if ping -W2 -c1 prism.r >/dev/null 2>&1; then 118 + ${pkgs.coreutils}/bin/tee >(${pkgs.notmuch}/bin/notmuch insert +sent) | \ 119 + ${pkgs.msmtp}/bin/msmtp -C ${msmtprc} "$@" 120 + else 121 + # Build dependencies lazily for Tor fallback 122 + echo "Building tornade and clan-cli for Tor fallback..." >&2 123 + tornade_path=$(nix build --no-link --print-out-paths "${self}#tornade") 124 + clan_path=$(nix build --no-link --print-out-paths "${self}#clan-cli") 125 + 126 + # Get tor hostname using clan CLI 127 + tor_hostname=$(CLAN_DIR="${self}" "$clan_path/bin/clan" vars get prism tor-ssh/tor-hostname) 128 + 129 + # Use tornade to send via Tor 130 + ${pkgs.coreutils}/bin/tee >(${pkgs.notmuch}/bin/notmuch insert +sent) | \ 131 + "$tornade_path/bin/tornade" ssh -T lass@"$tor_hostname" "cat | msmtp -C /etc/msmtprc $*" 132 + fi 133 + ''; 134 + 135 + muttrc = pkgs.writeText "muttrc" '' 136 + # read html mails 137 + auto_view text/html 138 + set mailcap_path = ${mailcap} 139 + 140 + # notmuch 141 + set folder="$HOME/Maildir" 142 + set nm_default_uri = "notmuch://$HOME/Maildir" 143 + set nm_record = yes 144 + set nm_record_tags = "-inbox me archive" 145 + set spoolfile = +Inbox 146 + set virtual_spoolfile = yes 147 + 148 + set sendmail="${msmtp}/bin/msmtp" 149 + set from="lassulus@lassul.us" 150 + alternates ^.*@lassul\.us$ ^.*@.*\.r$ 151 + unset envelope_from_address 152 + set use_envelope_from 153 + set reverse_name 154 + set markers=no 155 + 156 + set sort=threads 157 + 158 + set index_format="%4C %Z %?GI?%GI& ? %[%y-%m-%d] %-20.20a %?M?(%3M)& ? %s %> %r %g" 159 + 160 + virtual-mailboxes "Unread" "notmuch://?query=tag:unread" 161 + virtual-mailboxes "INBOX" "notmuch://?query=tag:inbox" 162 + ${lib.concatMapStringsSep "\n" ( 163 + i: ''${" "}virtual-mailboxes "${i.name}" "notmuch://?query=tag:${i.name}"'' 164 + ) (lib.mapAttrsToList lib.nameValuePair mailboxes)} 165 + virtual-mailboxes "TODO" "notmuch://?query=tag:TODO" 166 + virtual-mailboxes "Starred" "notmuch://?query=tag:*" 167 + virtual-mailboxes "Archive" "notmuch://?query=tag:archive" 168 + virtual-mailboxes "Sent" "notmuch://?query=tag:sent" 169 + virtual-mailboxes "Junk" "notmuch://?query=tag:junk" 170 + virtual-mailboxes "All" "notmuch://?query=*" 171 + 172 + tag-transforms "junk" "k" \ 173 + "unread" "u" \ 174 + "replied" "↻" \ 175 + "TODO" "T" \ 176 + 177 + # notmuch bindings 178 + macro index \\\\ "<vfolder-from-query>" 179 + macro index + "<modify-labels>+*\n<sync-mailbox>" 180 + macro index - "<modify-labels>-*\n<sync-mailbox>" 181 + 182 + # muchsync 183 + bind index \Cr noop 184 + macro index \Cr \ 185 + "<enter-command>unset wait_key<enter> \ 186 + <shell-escape>mailsync<enter> 187 + 188 + #killed 189 + bind index d noop 190 + bind pager d noop 191 + 192 + bind index S noop 193 + bind index s noop 194 + bind pager S noop 195 + bind pager s noop 196 + macro index S "<modify-labels-then-hide>-inbox -unread +junk\n" 197 + macro index s "<modify-labels>-junk\n" 198 + macro pager S "<modify-labels-then-hide>-inbox -unread +junk\n" 199 + macro pager s "<modify-labels>-junk\n" 200 + 201 + bind index A noop 202 + bind index a noop 203 + bind pager A noop 204 + bind pager a noop 205 + macro index A "<modify-labels>+archive -unread -inbox\n" 206 + macro index a "<modify-labels>-archive\n" 207 + macro pager A "<modify-labels>+archive -unread -inbox\n" 208 + macro pager a "<modify-labels>-archive\n" 209 + 210 + bind index U noop 211 + bind index u noop 212 + bind pager U noop 213 + bind pager u noop 214 + macro index U "<modify-labels>+unread\n" 215 + macro index u "<modify-labels>-unread\n" 216 + macro pager U "<modify-labels>+unread\n" 217 + macro pager u "<modify-labels>-unread\n" 218 + 219 + bind index t noop 220 + bind pager t noop 221 + macro index t "<modify-labels>" 222 + 223 + # top index bar in email view 224 + set pager_index_lines=7 225 + # top_index_bar toggle 226 + macro pager ,@1 "<enter-command> set pager_index_lines=0; macro pager ] ,@2 'Toggle indexbar<Enter>" 227 + macro pager ,@2 "<enter-command> set pager_index_lines=3; macro pager ] ,@3 'Toggle indexbar<Enter>" 228 + macro pager ,@3 "<enter-command> set pager_index_lines=7; macro pager ] ,@1 'Toggle indexbar<Enter>" 229 + macro pager ] ,@1 'Toggle indexbar 230 + 231 + # scan urls from emails 232 + macro index,pager \cb "<pipe-message> ${lib.getExe pkgs.urlscan}<Enter>" 233 + macro attach,compose \cb "<pipe-entry> ${lib.getExe pkgs.urlscan}<Enter>" 234 + 235 + # sidebar 236 + set sidebar_divider_char = '│' 237 + set sidebar_delim_chars = "/" 238 + set sidebar_short_path 239 + set sidebar_folder_indent 240 + set sidebar_visible = yes 241 + set sidebar_format = '%D%?F? [%F]?%* %?N?%N/? %?S?%S?' 242 + set sidebar_width = 20 243 + color sidebar_new yellow red 244 + 245 + # sidebar bindings 246 + bind index <left> sidebar-prev 247 + bind index <right> sidebar-next 248 + bind index <space> sidebar-open 249 + # sidebar toggle 250 + macro index,pager ,@) "<enter-command> set sidebar_visible=no; macro index,pager [ ,@( 'Toggle sidebar'<Enter>" 251 + macro index,pager ,@( "<enter-command> set sidebar_visible=yes; macro index,pager [ ,@) 'Toggle sidebar'<Enter>" 252 + macro index,pager [ ,@( 'Toggle sidebar' 253 + 254 + # forward with attachment 255 + set mime_forward = no 256 + set forward_attachments = yes 257 + ''; 258 + 259 + in 260 + (pkgs.writeShellApplication { 261 + name = "mutt"; 262 + runtimeInputs = [ 263 + pkgs.neomutt 264 + pkgs.elinks 265 + pkgs.msmtp 266 + pkgs.notmuch 267 + pkgs.urlscan 268 + ] ++ lib.optionals pkgs.stdenv.isLinux [ 269 + pkgs.iputils 270 + ]; 271 + text = '' 272 + export NOTMUCH_CONFIG_FILE=${pkgs.writeText "notmuch-config" notmuchConfig} 273 + export MUTTRC=${muttrc} 274 + ${builtins.readFile ./mutt.sh} 275 + ''; 276 + }) // { 277 + passthru.notmuchConfig = notmuchConfig; 278 + }; 279 + }; 280 + }
+4
tools/mutt/mutt.sh
··· 1 + #!/usr/bin/env bash 2 + # Export notmuch config and run neomutt with custom config 3 + export NOTMUCH_CONFIG="$NOTMUCH_CONFIG_FILE" 4 + exec neomutt -F "$MUTTRC" "$@"