diff --git a/users/simon/modules/default.nix b/users/simon/modules/default.nix index 9f15777..4e70b64 100644 --- a/users/simon/modules/default.nix +++ b/users/simon/modules/default.nix @@ -2,6 +2,7 @@ imports = [ ./alacritty.nix ./anki.nix + ./email.nix ./games.nix ./git.nix ./gpg.nix diff --git a/users/simon/modules/email.nix b/users/simon/modules/email.nix new file mode 100644 index 0000000..cbabb91 --- /dev/null +++ b/users/simon/modules/email.nix @@ -0,0 +1,141 @@ +{ config, lib, pkgs, ... }: +let + virtualMailboxes = { + "FabLab" = "body:fablab"; + "Git" = "from:{.*@github.com or .*@gitlab.com or no-reply+gitea@sbruder.de}'"; + }; + + mkVirtualMailbox = name: searchTerm: '' + virtual-mailboxes "${name}" "notmuch://?query=${searchTerm}" + ''; + + mutt-solarized-dark = pkgs.fetchurl { + url = "https://raw.githubusercontent.com/altercation/mutt-colors-solarized/b1520c6bf1ab49538439514c9393ff69df8591b4/mutt-colors-solarized-dark-16.muttrc"; + sha256 = "0lji8lds9xqj3j5qpn5554rk8gqx72mc6dc57j3j3kb20xvnq5cx"; + + meta.license = lib.licenses.mit; + }; +in +{ + accounts.email = { + maildirBasePath = "${config.xdg.dataHome}/mail"; + + accounts = { + personal = rec { + primary = true; + + realName = "Simon Bruder"; + address = "simon@sbruder.de"; + aliases = [ ]; # FIXME!? + + userName = address; + passwordCommand = "pass sbruder.de/account | head -n 1"; + + imap = { + host = "home.sbruder.de"; + tls.useStartTls = true; + }; + + smtp = { + host = "home.sbruder.de"; + tls.useStartTls = true; + }; + + signature = { + showSignature = "append"; + text = '' + Simon Bruder + + 🔑 (GPG): 47E7 559E 037A 3565 2DBB F8AA 8D3C 82F9 F309 F8EC + 📧 (E-Mail): simon@sbruder.de + 📱 (mobile): +49 152 56561414 + ''; + }; + + gpg = { + key = config.programs.gpg.settings.default-key; + signByDefault = true; + encryptByDefault = true; + }; + + msmtp.enable = true; + mbsync = { + enable = true; + #flatten = "."; + create = "both"; + expunge = "both"; + }; + #mu.enable = true; + neomutt = { + enable = true; + extraConfig = let account = config.accounts.email.accounts.personal; in + '' + # revert home-manager setting + unmailboxes "${account.maildir.absPath}/${account.folders.inbox}" + unvirtual-mailboxes "My INBOX" + ''; + }; + notmuch.enable = true; + }; + }; + }; + + programs.neomutt = { + enable = true; + + sidebar = { + enable = true; + format = "%B%?F? [%F]?%* %?N?%N/?%S"; + }; + + binds = [ + { map = "index"; key = "\\\\"; action = "vfolder-from-query"; } + ]; + + extraConfig = '' + source ${mutt-solarized-dark} + + ${mkVirtualMailbox "Inbox" "tag:inbox"} + ${lib.concatStringsSep + "\n" + (lib.attrValues + (lib.mapAttrs mkVirtualMailbox virtualMailboxes))} + ''; + + # somehow makes not work (?) + #vimKeys = true; + settings = { + wait_key = "yes"; + timeout = "3"; + quit = "yes"; + mail_check_stats = "yes"; + + edit_headers = "yes"; + reverse_name = "yes"; + include = "yes"; + + mailcap_path = toString (pkgs.writeText "mutt-mailcap" '' + text/html; firefox %s + text/html; ${pkgs.w3m}/bin/w3m -I %{charset} -T text/html -dump; copiousoutput; + application/pdf; zathura %s + image/*; mpv %s + ''); + + pgp_default_key = config.programs.gpg.settings.default-key; + + nm_query_type = "threads"; + }; + }; + + programs.mbsync.enable = true; + programs.msmtp.enable = true; + #programs.mu.enable = true; + programs.notmuch = { + enable = true; + hooks = { + preNew = '' + mbsync --all + ''; + }; + }; +}