diff --git a/home/aselimov/email.nix b/home/aselimov/email.nix new file mode 100644 index 0000000..ec3b3e8 --- /dev/null +++ b/home/aselimov/email.nix @@ -0,0 +1,143 @@ +{config, pkgs, ... }: +let + mailNotify = pkgs.writeShellScript "mail-notify" '' + set -euo pipefail + + ${pkgs.notmuch}/bin/notmuch new >/dev/null + + ${pkgs.notmuch}/bin/notmuch search \ + --format=json \ + 'tag:new' | + ${pkgs.jq}/bin/jq -r '.[] | [.authors, .subject] | @tsv' | + while IFS=$'\t' read -r sender subject; do + ${pkgs.libnotify}/bin/notify-send \ + --app-name="Mail" \ + "New email from $sender" \ + "$subject" + done + + # Don't notify about these messages again next sync. + ${pkgs.notmuch}/bin/notmuch tag -new -- 'tag:new' + ''; +in +{ + accounts.email = { + maildirBasePath = "Mail"; + + accounts.personal = { + primary = true; + address = "alex@alexselimov.com"; + realName = "Alex Selimov"; + userName = "alex"; + + passwordCommand = "${pkgs.pass}/bin/pass show alex@alexselimov.xyz"; + + imap = { + host = "mail.alexselimov.com"; + port = 993; + + tls = { + enable = true; + useStartTls = false; + }; + }; + + maildir.path = "alex@alexselimov.com"; + + smtp = { + host = "mail.alexselimov.com"; + port = 587; + + tls = { + enable = true; + useStartTls = true; + }; + }; + mbsync = { + enable = true; + create = "both"; + }; + notmuch.enable = true; + aerc = { + enable = true; + extraAccounts = { + source = "notmuch://"; + }; + }; + }; + }; + + programs.mbsync.enable = true; + services.mbsync = { + enable = true; + frequency = "*:0/1"; + postExec = "${mailNotify}"; + }; + + programs.aerc = { + enable = true; + + extraConfig = { + general = { + unsafe-accounts-conf = true; + }; + ui.styleset-name = "zenwritten"; + filters = { + "text/plain" = "wrap -w 100 | colorize"; + "text/html" = "html | colorize"; + }; + + compose = { + editor = "nvim"; + }; + + viewer = { + pager = "less -R"; + }; + }; + + }; + + xdg.configFile."aerc/binds.conf".text = '' + ${builtins.readFile "${pkgs.aerc}/share/aerc/binds.conf"} + + [messages] + l = :view + ''; + + programs.notmuch = { + enable = true; + + new.tags = [ + "new" + "unread" + "inbox" + ]; + + extraConfig = { + user = { + name = "Alex Selimov"; + primary_email = "alex@alexselimov.com"; + }; + }; + }; + + xdg.configFile."aerc/stylesets/zenwritten".text = '' + *.default=true + *.normal=true + *.fg=default + *.bg=default + + *.selected.reverse=toggle + + title.bold=true + header.bold=true + msglist_unread.bold=true + dirlist_recent.bold=true + ''; + + xdg.configFile."aerc/mimeapps.conf".text = '' + text/html=xdg-open + ''; +} + diff --git a/home/aselimov/home.nix b/home/aselimov/home.nix index fbc315c..dfc5f1a 100644 --- a/home/aselimov/home.nix +++ b/home/aselimov/home.nix @@ -24,6 +24,7 @@ in ./theme/theme.nix ./fuzzel.nix ./mako.nix + ./email.nix ]; home.username = "aselimov"; home.homeDirectory = "/home/aselimov"; @@ -65,6 +66,7 @@ in dino wtype libnotify + prusa-slicer ]; home.pointerCursor = { enable = true;