aboutsummaryrefslogtreecommitdiffstats
path: root/modules/communication/neomutt/account
diff options
context:
space:
mode:
authorArpit Chakladar <arpit@chakladar.me>2026-09-30 03:09:58 +0530
committerArpit Chakladar <arpit@chakladar.me>2026-09-30 03:09:58 +0530
commit77becc9d521490a71560fa87ee33e4f600839cfd (patch)
tree95659d5273b773012dd9ac34358d69e60f2c9b9b /modules/communication/neomutt/account
parentfe64e34d2451e33623632c4a4ee216101d18dcc5 (diff)
downloadhome-manager-config-77becc9d521490a71560fa87ee33e4f600839cfd.tar.gz
home-manager-config-77becc9d521490a71560fa87ee33e4f600839cfd.zip
feat(communication/neomutt): reworked the email syncing
Now we have the ability to map each folder on the remote server with a folder with an arbitrary name in the local server. Each folder gets its own channel with quick and full variations where the quick only download the new emails from the remote to the local and full makes a sync both ways.
Diffstat (limited to 'modules/communication/neomutt/account')
-rw-r--r--modules/communication/neomutt/account/.neomuttrc4
-rw-r--r--modules/communication/neomutt/account/default.nix36
-rw-r--r--modules/communication/neomutt/account/flavors/gmail/.neomuttrc2
-rw-r--r--modules/communication/neomutt/account/flavors/gmail/default.nix28
-rw-r--r--modules/communication/neomutt/account/options.nix8
-rw-r--r--modules/communication/neomutt/account/sync-channel.nix11
6 files changed, 63 insertions, 26 deletions
diff --git a/modules/communication/neomutt/account/.neomuttrc b/modules/communication/neomutt/account/.neomuttrc
index 2f8c9f2..37dc9aa 100644
--- a/modules/communication/neomutt/account/.neomuttrc
+++ b/modules/communication/neomutt/account/.neomuttrc
@@ -1,2 +1,2 @@
-macro index,pager gs "<enter-command>set my_wait_key=$wait_key wait_key=no<enter><sync-mailbox><shell-escape>neomutt-sync @@QUICK_CHANNEL@@<enter><sync-mailbox><enter-command>set wait_key=$my_wait_key<enter>"
-macro index,pager gS "<enter-command>set my_wait_key=$wait_key wait_key=no<enter><sync-mailbox><shell-escape>neomutt-sync @@FULL_CHANNEL@@<enter><sync-mailbox><enter-command>set wait_key=$my_wait_key<enter>"
+macro index,pager gs "<enter-command>set my_wait_key=$wait_key wait_key=no<enter><sync-mailbox><shell-escape>neomutt-sync @@QUICK_GROUP@@<enter><sync-mailbox><enter-command>set wait_key=$my_wait_key<enter>"
+macro index,pager gS "<enter-command>set my_wait_key=$wait_key wait_key=no<enter><sync-mailbox><shell-escape>neomutt-sync @@FULL_GROUP@@<enter><sync-mailbox><enter-command>set wait_key=$my_wait_key<enter>"
diff --git a/modules/communication/neomutt/account/default.nix b/modules/communication/neomutt/account/default.nix
index 07a4b89..1d8046a 100644
--- a/modules/communication/neomutt/account/default.nix
+++ b/modules/communication/neomutt/account/default.nix
@@ -2,6 +2,7 @@
{ config, lib, ... }:
let
cfg = config.communication.neomutt;
+ mbsyncGroupNames = (import ../lib.nix { inherit lib; }).mbsyncGroupNames;
in
{
imports = [
@@ -47,10 +48,10 @@ in
inherit (accountInformation.folders) inbox trash;
}
// lib.optionalAttrs (accountInformation.folders.drafts != null) {
- drafts = accountInformation.folders.drafts;
+ inherit (accountInformation.folders) drafts;
}
// lib.optionalAttrs (accountInformation.folders.sent != null) {
- sent = accountInformation.folders.sent;
+ inherit (accountInformation.folders) sent;
};
neomutt = {
@@ -62,14 +63,43 @@ in
mbsync = {
enable = true;
create = accountInformation.mbsync.create;
+ expunge = "both";
patterns = accountInformation.mbsync.patterns;
flatten = accountInformation.mbsync.flatten;
extraConfig = {
- account = accountInformation.mbsync.extraConfig.account;
+ account = {
+ PipelineDepth = 50;
+ }
+ // accountInformation.mbsync.extraConfig.account;
channel = accountInformation.mbsync.extraConfig.channel;
local = accountInformation.mbsync.extraConfig.local;
remote = accountInformation.mbsync.extraConfig.remote;
};
+
+ groups =
+ let
+ group = mbsyncGroupNames accountName;
+
+ mkChannels =
+ sync:
+ lib.mapAttrs (local: remote: {
+ farPattern = remote;
+ nearPattern = local;
+ extraConfig = {
+ Create = "Near";
+ Expunge = "Both";
+ Sync = sync;
+ SyncState = "*";
+ };
+ }) accountInformation.mbsync.folders.map;
+ in
+ {
+ "${group.full}".channels = mkChannels "All";
+ "${group.quick}".channels = mkChannels [
+ "Pull"
+ "New"
+ ];
+ };
};
notmuch = {
diff --git a/modules/communication/neomutt/account/flavors/gmail/.neomuttrc b/modules/communication/neomutt/account/flavors/gmail/.neomuttrc
index c87bba0..2106b65 100644
--- a/modules/communication/neomutt/account/flavors/gmail/.neomuttrc
+++ b/modules/communication/neomutt/account/flavors/gmail/.neomuttrc
@@ -1,2 +1,2 @@
-mailboxes =Inbox ="[Gmail]/Drafts" ="[Gmail]/Sent Mail" ="[Gmail]/Spam" ="[Gmail]/Trash"
+mailboxes =inbox =drafts =sent =spam =trash
unset record
diff --git a/modules/communication/neomutt/account/flavors/gmail/default.nix b/modules/communication/neomutt/account/flavors/gmail/default.nix
index b0b7733..ea696b2 100644
--- a/modules/communication/neomutt/account/flavors/gmail/default.nix
+++ b/modules/communication/neomutt/account/flavors/gmail/default.nix
@@ -8,25 +8,25 @@
{
config = lib.mkIf (config.flavor == "gmail.com") {
folders = {
- inbox = lib.mkDefault "Inbox";
- drafts = lib.mkDefault "[Gmail]/Drafts";
- sent = lib.mkDefault "[Gmail]/Sent Mail";
- trash = lib.mkDefault "[Gmail]/Trash";
+ inbox = lib.mkDefault "inbox";
+ drafts = lib.mkDefault "drafts";
+ sent = lib.mkDefault "sent";
+ trash = lib.mkDefault "trash";
};
mbsync = {
create = lib.mkDefault "maildir";
- patterns = lib.mkDefault [
- "INBOX"
- "[Gmail]/Drafts"
- "[Gmail]/Sent Mail"
- "[Gmail]/Spam"
- ];
+ patterns = lib.mkDefault [ "INBOX" ];
+ folders.map = lib.mkDefault {
+ inbox = "INBOX";
+ drafts = "[Gmail]/Drafts";
+ sent = "[Gmail]/Sent Mail";
+ spam = "[Gmail]/Spam";
+ trash = "[Gmail]/Trash";
+ };
extraConfig.channel = {
Sync = lib.mkDefault "All";
CopyArrivalDate = lib.mkDefault "yes";
- Expunge = lib.mkDefault "Both";
- SyncState = lib.mkDefault "*";
};
};
@@ -34,8 +34,8 @@
notmuch.neomutt.virtual-mailboxes = lib.mkDefault [
{
- name = "All Mail";
- query = "folder:${name}/Inbox or folder:\"${name}/[Gmail]/Sent Mail\"";
+ name = "all";
+ query = "folder:${name}/inbox or folder:\"${name}/sent\"";
}
];
};
diff --git a/modules/communication/neomutt/account/options.nix b/modules/communication/neomutt/account/options.nix
index 676f8b0..3090db2 100644
--- a/modules/communication/neomutt/account/options.nix
+++ b/modules/communication/neomutt/account/options.nix
@@ -121,6 +121,14 @@
description = "Flatten hierarchy delimiter.";
};
+ folders = {
+ map = lib.mkOption {
+ type = lib.types.attrsOf lib.types.str;
+ default = { };
+ description = "Local folder name -> remote folder name, for folders that should be renamed locally.";
+ };
+ };
+
extraConfig = {
account = lib.mkOption {
type = lib.types.attrsOf (
diff --git a/modules/communication/neomutt/account/sync-channel.nix b/modules/communication/neomutt/account/sync-channel.nix
index 2252594..cb966c8 100644
--- a/modules/communication/neomutt/account/sync-channel.nix
+++ b/modules/communication/neomutt/account/sync-channel.nix
@@ -5,20 +5,19 @@
...
}:
let
-
- mbsyncNamesFromName = (import ../lib.nix { inherit lib; }).mbsyncNamesFromName;
+ mbsyncGroupNames = (import ../lib.nix { inherit lib; }).mbsyncGroupNames;
in
{
config = lib.mkIf config.enable {
neomutt.extraConfig =
let
- mbsyncNames = mbsyncNamesFromName name;
+ group = mbsyncGroupNames name;
in
builtins.replaceStrings
- [ "@@QUICK_CHANNEL@@" "@@FULL_CHANNEL@@" ]
+ [ "@@QUICK_GROUP@@" "@@FULL_GROUP@@" ]
[
- mbsyncNames.channels.quick
- mbsyncNames.channels.full
+ group.quick
+ group.full
]
(builtins.readFile ./.neomuttrc);
};