aboutsummaryrefslogtreecommitdiffstats
path: root/modules/communication/neomutt/mail
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/mail
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/mail')
-rw-r--r--modules/communication/neomutt/mail/mbsync.nix89
1 files changed, 0 insertions, 89 deletions
diff --git a/modules/communication/neomutt/mail/mbsync.nix b/modules/communication/neomutt/mail/mbsync.nix
index b93b134..66964e0 100644
--- a/modules/communication/neomutt/mail/mbsync.nix
+++ b/modules/communication/neomutt/mail/mbsync.nix
@@ -6,98 +6,9 @@
}:
let
cfg = config.communication.neomutt;
-
- mbsyncNamesFromName = (import ../lib.nix { inherit lib; }).mbsyncNamesFromName;
-
- mbsyncValue =
- value:
- if lib.isList value then
- lib.concatStringsSep " " (map mbsyncValue value)
- else if lib.isBool value then
- lib.hm.booleans.yesNo value
- else if lib.isInt value then
- toString value
- else if lib.isString value then
- if builtins.match ".* .*" value != null then ''"${lib.escape [ ''"'' ] value}"'' else value
- else
- throw "Unsupported mbsync value";
-
- mbsyncSection = name: attrs: ''
- ${name}
- ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n} ${mbsyncValue v}") attrs)}
- '';
-
- mbsyncAccount =
- account:
- let
- mbsyncNames = mbsyncNamesFromName account.name;
- in
- lib.concatStringsSep "\n" [
- (mbsyncSection "IMAPAccount ${mbsyncNames.base}" (
- {
- Host = account.imap.host;
- User = account.userName;
- PipelineDepth = 50;
- TLSType =
- if !account.imap.tls.enable then
- "None"
- else if account.imap.tls.useStartTls then
- "STARTTLS"
- else
- "IMAPS";
- }
- // lib.optionalAttrs (account.passwordCommand != null) {
- PassCmd = toString account.passwordCommand;
- }
- // lib.optionalAttrs (account.imap.tls.certificatesFile != null) {
- CertificateFile = toString account.imap.tls.certificatesFile;
- }
- // lib.optionalAttrs (account.imap.port != null) {
- Port = account.imap.port;
- }
- ))
-
- (mbsyncSection "IMAPStore ${mbsyncNames.servers.remote}" {
- Account = mbsyncNames.base;
- })
-
- (mbsyncSection "MaildirStore ${mbsyncNames.servers.local}" {
- Path = "${account.maildir.absPath}/";
- Inbox = "${account.maildir.absPath}/${account.folders.inbox}";
- SubFolders = "Verbatim";
- })
-
- (mbsyncSection "Channel ${mbsyncNames.channels.quick}" {
- Far = ":${mbsyncNames.servers.remote}:\"INBOX\"";
- Near = ":${mbsyncNames.servers.local}:\"INBOX\"";
- Create = "Near";
- Expunge = "None";
- Sync = [
- "Pull"
- "New"
- ];
- SyncState = "*";
- })
-
- (mbsyncSection "Channel ${mbsyncNames.channels.full}" {
- Far = ":${mbsyncNames.servers.remote}:";
- Near = ":${mbsyncNames.servers.local}:";
- Patterns = account.mbsync.patterns;
- Create = "Near";
- Expunge = "Both";
- Sync = "All";
- SyncState = "*";
- })
- ];
-
- accounts = lib.filter (account: account.enable && account.mbsync.enable) (
- lib.attrValues config.accounts.email.accounts
- );
in
{
config = lib.mkIf cfg.enable {
programs.mbsync.enable = true;
-
- xdg.configFile."mbsync/.mbsyncrc".text = lib.concatStringsSep "\n" (map mbsyncAccount accounts);
};
}