diff options
Diffstat (limited to 'modules/communication/neomutt/default.nix')
| -rw-r--r-- | modules/communication/neomutt/default.nix | 52 |
1 files changed, 21 insertions, 31 deletions
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"; |
