diff options
author | Franck Cuny <franck@fcuny.net> | 2022-02-13 19:29:09 -0800 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2022-02-13 19:29:09 -0800 |
commit | 2970cd995f78ca1d574370539ccde83181e72dbb (patch) | |
tree | c2ace1ae6687ac53028a44f46bac007874d7af1d | |
parent | password-store: use the correct variable (diff) | |
download | world-2970cd995f78ca1d574370539ccde83181e72dbb.tar.gz |
email: add initial email configuration
Configure the account and pull with mbsync. We run notmuch after the pull.
Diffstat (limited to '')
-rw-r--r-- | users/fcuny/desktop/trust/default.nix | 1 | ||||
-rw-r--r-- | users/fcuny/desktop/trust/email.nix | 71 |
2 files changed, 72 insertions, 0 deletions
diff --git a/users/fcuny/desktop/trust/default.nix b/users/fcuny/desktop/trust/default.nix index cc5e70a..575d3e6 100644 --- a/users/fcuny/desktop/trust/default.nix +++ b/users/fcuny/desktop/trust/default.nix @@ -2,6 +2,7 @@ { imports = [ + ./email.nix ./git.nix ./pass.nix ./pgp.nix diff --git a/users/fcuny/desktop/trust/email.nix b/users/fcuny/desktop/trust/email.nix new file mode 100644 index 0000000..641166e --- /dev/null +++ b/users/fcuny/desktop/trust/email.nix @@ -0,0 +1,71 @@ +{ pkgs, config, lib, ... }: + +{ + accounts.email = { + maildirBasePath = "${config.home.homeDirectory}/.mail"; + accounts = { + fastmail = rec { + primary = true; + address = "franck@fcuny.net"; + userName = address; + passwordCommand = "pass email/imap.fastmail.com"; + imap.host = "imap.fastmail.com"; + mbsync = { + enable = true; + create = "maildir"; + expunge = "both"; + }; + notmuch.enable = true; + }; + }; + }; + + programs.mbsync.enable = true; + + programs.notmuch = { + enable = true; + maildir.synchronizeFlags = true; + new.tags = [ "new" ]; + search.excludeTags = [ "spam" ]; + }; + + xdg.configFile."mbsync/imap-sync.sh" = { + executable = true; + text = '' + #!${pkgs.stdenv.shell} + MAILDIR=$HOME/.mail/ + + # Strip UIDs from filenames when moving mails so that mbsync doesn't get confused. + mv_renamed() { + while IFS= read -r name; do + flags=$(echo "$name" | cut -d':' -f2) + new_name="$(basename $name | awk -F ',' '{print $1}')" + [ -f "$name" ] && mv -nv "${name}" "${1}/${new_name}" + done + } + + ${pkgs.notmuch}/bin/notmuch search --output=files -- not tag:inbox and folder:Fastmail/Inbox | mv_renamed ${MAILDIR}/Fastmail/Archive/cur + ''; + }; + + systemd.user.services.mbsync = { + Unit = { + Description = "mbsync synchronization"; + }; + Service = { + Type = "oneshot"; + ExecStartPre = "${config.xdg.configFile}/mbsync/imap-sync.sh"; + ExecStart = "${pkgs.isync}/bin/mbsync -a"; + ExecStartPost = "${pkgs.notmuch}/bin/notmuch new --quiet"; + }; + }; + + systemd.user.timers.mbsync = { + Unit = { Description = "mbsync synchronization"; }; + Timer = { + OnBootSec = "30"; + OnUnitActiveSec = "5m"; + }; + Install = { WantedBy = [ "timers.target" ]; }; + }; +} |