From 77becc9d521490a71560fa87ee33e4f600839cfd Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Wed, 30 Sep 2026 03:09:58 +0530 Subject: 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. --- modules/communication/neomutt/default.nix | 52 +++++++++++++------------------ 1 file changed, 21 insertions(+), 31 deletions(-) (limited to 'modules/communication/neomutt/default.nix') diff --git a/modules/communication/neomutt/default.nix b/modules/communication/neomutt/default.nix index 6189b23..40c8950 100644 --- a/modules/communication/neomutt/default.nix +++ b/modules/communication/neomutt/default.nix @@ -8,16 +8,7 @@ let cfg = config.communication.neomutt; icons = config.desktop.icons.apps; - - mbsyncNamesFromName = (import ./lib.nix { inherit lib; }).mbsyncNamesFromName; - - fullSyncChannels = lib.mapAttrsToList (name: account: (mbsyncNamesFromName name).channels.full) ( - lib.filterAttrs (name: account: account.enable) cfg.accounts - ); - - quickSyncChannels = lib.mapAttrsToList (name: account: (mbsyncNamesFromName name).channels.quick) ( - lib.filterAttrs (name: account: account.enable) cfg.accounts - ); + mbsyncGroupNames = (import ./lib.nix { inherit lib; }).mbsyncGroupNames; neomuttSyncScript = pkgs.writeShellApplication { name = "neomutt-sync"; @@ -34,27 +25,26 @@ let text = builtins.readFile ./neomutt-sync.sh; }; - neomuttSyncDaemon = pkgs.writeShellApplication { - name = "neomutt-sync-daemon"; - runtimeInputs = [ - config.terminal.bash.package - pkgs.coreutils - pkgs.procps - config.programs.mbsync.package - config.programs.notmuch.package - ]; - text = - builtins.replaceStrings - [ - "@@QUICK_CHANNELS@@" - "@@FULL_CHANNELS@@" - ] - [ - (lib.concatStringsSep "," quickSyncChannels) - (lib.concatStringsSep "," fullSyncChannels) - ] - (builtins.readFile ./neomutt-sync-daemon.sh); - }; + neomuttSyncDaemon = + let + accountNames = lib.attrNames (lib.filterAttrs (_: a: a.enable) cfg.accounts); + groupsFor = kind: lib.concatStringsSep "," (map (n: (mbsyncGroupNames n).${kind}) accountNames); + in + pkgs.writeShellApplication { + name = "neomutt-sync-daemon"; + runtimeInputs = [ + config.terminal.bash.package + pkgs.coreutils + pkgs.procps + config.programs.mbsync.package + config.programs.notmuch.package + ]; + text = + lib.replaceStrings + [ "@@QUICK_GROUPS@@" "@@FULL_GROUPS@@" ] + [ (groupsFor "quick") (groupsFor "full") ] + (builtins.readFile ./neomutt-sync-daemon.sh); + }; neomuttLauncher = pkgs.writeShellApplication { name = "neomutt-launcher"; -- cgit v1.2.3