about summary refs log tree commit diff
path: root/home/mail
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-04-08 08:30:17 -0700
committerFranck Cuny <franck@fcuny.net>2022-04-08 08:30:17 -0700
commit2aa3e62136109c5c4762e951525d68aff3e1ac5a (patch)
tree0f508cad82717ac70c7da5fd402c9555ce9166d1 /home/mail
parenthome: fix for yt-dlp configuration (diff)
downloadworld-2aa3e62136109c5c4762e951525d68aff3e1ac5a.tar.gz
home: add more configurations for home-manager
Diffstat (limited to 'home/mail')
-rw-r--r--home/mail/accounts/default.nix71
-rw-r--r--home/mail/default.nix11
2 files changed, 82 insertions, 0 deletions
diff --git a/home/mail/accounts/default.nix b/home/mail/accounts/default.nix
new file mode 100644
index 0000000..3a9a0e4
--- /dev/null
+++ b/home/mail/accounts/default.nix
@@ -0,0 +1,71 @@
+{ config, lib, pkgs, ... }:
+let cfg = config.my.home.mail;
+in {
+  config = lib.mkIf cfg.enable {
+    accounts.email = {
+      accounts = {
+        Fastmail = rec {
+          primary = true;
+          address = "franck@fcuny.net";
+          userName = address;
+          realName = "Franck Cuny";
+          aliases = [ "franck.cuny@gmail.com" ];
+          passwordCommand = "pass email/imap.fastmail.com";
+          imap.host = "imap.fastmail.com";
+          mbsync = {
+            enable = true;
+            create = "maildir";
+            expunge = "both";
+            extraConfig.channel.CopyArrivalDate = "yes";
+          };
+          notmuch.enable = true;
+        };
+      };
+    };
+
+    programs.mbsync.enable = true;
+
+    programs.afew = {
+      enable = true;
+      extraConfig = ''
+        [SpamFilter]
+        [KillThreadsFilter]
+        [ArchiveSentMailsFilter]
+        [InboxFilter]
+      '';
+    };
+
+    programs.notmuch = {
+      enable = true;
+      maildir.synchronizeFlags = true;
+      new.tags = [ "unread" "inbox" ];
+      new.ignore = [ "Trash" ];
+      search.excludeTags = [ "spam" "deleted" ];
+      hooks = {
+        postNew = "${config.home.profileDirectory}/bin/afew -v --tag --new";
+      };
+    };
+
+    systemd.user.services.mbsync = {
+      Unit = { Description = "mbsync synchronization"; };
+      Service = {
+        Type = "oneshot";
+        Environment = [
+          "PASSWORD_STORE_DIR=${config.programs.password-store.settings.PASSWORD_STORE_DIR}"
+          "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc"
+        ];
+        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" ]; };
+    };
+  };
+}
diff --git a/home/mail/default.nix b/home/mail/default.nix
new file mode 100644
index 0000000..4f36e87
--- /dev/null
+++ b/home/mail/default.nix
@@ -0,0 +1,11 @@
+{ config, lib, ... }:
+let
+  cfg = config.my.home.mail;
+  mkRelatedOption = desc: lib.mkEnableOption desc // { default = cfg.enable; };
+in {
+  imports = [ ./accounts ];
+  options.my.home.mail = with lib; {
+    enable = mkEnableOption "email configuration";
+  };
+  config = { accounts.email = { maildirBasePath = ".mail"; }; };
+}