diff options
Diffstat (limited to 'modules/communication/neomutt/default.nix')
| -rw-r--r-- | modules/communication/neomutt/default.nix | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/modules/communication/neomutt/default.nix b/modules/communication/neomutt/default.nix index e091a7d..6bc363b 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.writeShellApplication { + name = "neomutt-launcher"; + runtimeInputs = [ + pkgs.systemd + pkgs.procps + pkgs.neomutt + pkgs.urlscan + ]; + text = + builtins.replaceStrings + [ + "@@NEOMUTT_BIN@@" + ] + [ + (lib.getExe pkgs.neomutt) + ] + (builtins.readFile ./neomutt-launcher.sh); + }; + neomuttSyncCompletion = pkgs.runCommand "neomutt-sync-completion" { @@ -71,21 +108,18 @@ in builtins.replaceStrings [ "@@HTML_VIEWER@@" ] [ (lib.getExe config.web.chawan.package) ] (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"; + "${config.programs.neomutt.package}/share/neomutt/logo/neomutt.svg"; + programs.neomutt = { enable = true; package = pkgs.symlinkJoin { name = "neomutt-wrapped"; paths = [ + neomuttLauncher pkgs.neomutt neomuttSync ]; - nativeBuildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/neomutt \ - --prefix PATH : ${config.home.profileDirectory}/bin:${lib.makeBinPath [ pkgs.urlscan ]} - ''; - meta.mainProgram = "neomutt"; + meta.mainProgram = "neomutt-launcher"; }; sidebar.enable = true; sort = "reverse-threads"; @@ -96,6 +130,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" = { |
