diff options
| author | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-24 04:40:56 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-24 04:40:56 +0530 |
| commit | 9254d170236eeb9d9e113915c89ec4cab34a5f98 (patch) | |
| tree | 3abd9baca5b20db9903b1d652e1f3c0c7a3157a7 /modules/communication/neomutt/default.nix | |
| parent | 3a6e45ad18c519b21c9cadb2d374148647886b05 (diff) | |
| download | home-manager-config-9254d170236eeb9d9e113915c89ec4cab34a5f98.tar.gz home-manager-config-9254d170236eeb9d9e113915c89ec4cab34a5f98.zip | |
feat(communication/neomutt): added auto syncing daemon that runs with the client
Diffstat (limited to 'modules/communication/neomutt/default.nix')
| -rw-r--r-- | modules/communication/neomutt/default.nix | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/modules/communication/neomutt/default.nix b/modules/communication/neomutt/default.nix index e091a7d..3354213 100644 --- a/modules/communication/neomutt/default.nix +++ b/modules/communication/neomutt/default.nix @@ -8,6 +8,12 @@ let cfg = config.communication.neomutt; + mbsyncNamesFromName = (import ./lib.nix { inherit lib; }).mbsyncNamesFromName; + + fullSyncChannels = lib.mapAttrsToList (name: account: (mbsyncNamesFromName name).channels.full) ( + lib.filterAttrs (name: account: account.enable) config.communication.neomutt.accounts + ); + neomuttSyncScript = pkgs.writeShellApplication { name = "neomutt-sync"; runtimeInputs = [ @@ -23,6 +29,37 @@ 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.readFile ./neomutt-sync-daemon.sh; + }; + + neomuttLauncher = pkgs.writeShellScriptBin "neomutt" ( + builtins.replaceStrings + [ + "@@SYSTEMCTL@@" + "@@PGREP@@" + "@@NEOMUTT@@" + "@@PROFILE_BIN@@" + "@@URLSCAN_BIN@@" + ] + [ + (lib.getExe' pkgs.systemd "systemctl") + (lib.getExe' pkgs.procps "pgrep") + (lib.getExe pkgs.neomutt) + "${config.home.profileDirectory}/bin" + (lib.makeBinPath [ pkgs.urlscan ]) + ] + (builtins.readFile ./neomutt-launcher.sh) + ); + neomuttSyncCompletion = pkgs.runCommand "neomutt-sync-completion" { @@ -72,19 +109,15 @@ in (builtins.readFile ./mailcap); home.file.".local/share/icons/hicolor/scalable/apps/neomutt.svg".source = config.lib.file.mkOutOfStoreSymlink "${config.programs.neomutt.package}/share/neomutt/logo/neomutt.svg"; + programs.neomutt = { enable = true; package = pkgs.symlinkJoin { name = "neomutt-wrapped"; paths = [ - pkgs.neomutt + neomuttLauncher neomuttSync ]; - nativeBuildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/neomutt \ - --prefix PATH : ${config.home.profileDirectory}/bin:${lib.makeBinPath [ pkgs.urlscan ]} - ''; meta.mainProgram = "neomutt"; }; sidebar.enable = true; @@ -96,6 +129,16 @@ in builtins.readFile ./.neomuttrc ); }; + + systemd.user.services.neomutt-sync = { + Unit = { + Description = "Full mail sync while neomutt is running"; + }; + Service = { + Type = "simple"; + ExecStart = "${lib.getExe neomuttSyncDaemon} ${lib.concatStringsSep " " fullSyncChannels}"; + }; + }; }) (lib.mkIf (cfg.enable && config.terminal.kitty.enable) { xdg.desktopEntries."neomutt" = { |
