diff options
| author | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:45:10 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:50:33 +0530 |
| commit | 1a39cf221e3f647df0767c88d89a54e3813e7019 (patch) | |
| tree | b3df1afb0bcc0942a364f267f993ed1a9bfb9434 /modules/communication/neomutt/default.nix | |
| parent | e9e375f5f5263964fe89479a2610081000959774 (diff) | |
| download | home-manager-config-1a39cf221e3f647df0767c88d89a54e3813e7019.tar.gz home-manager-config-1a39cf221e3f647df0767c88d89a54e3813e7019.zip | |
refactor: adding explicit options to enable scripts
- some scripts that are not critical to the functioning of other
options, can be enabled/disabled
Diffstat (limited to 'modules/communication/neomutt/default.nix')
| -rw-r--r-- | modules/communication/neomutt/default.nix | 90 |
1 files changed, 62 insertions, 28 deletions
diff --git a/modules/communication/neomutt/default.nix b/modules/communication/neomutt/default.nix index 8e5d51b..e8496e1 100644 --- a/modules/communication/neomutt/default.nix +++ b/modules/communication/neomutt/default.nix @@ -6,16 +6,9 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - neomuttSync = mkScriptModule { - scope = [ - "communication" - "neomutt" - ]; + neomuttSyncScript = pkgs.writeShellApplication { name = "neomutt-sync"; - path = ./neomutt-sync.sh; - description = "Neomutt-sync - Interactive mail sync with dialog progress bar"; - deps = [ + runtimeInputs = [ pkgs.bash pkgs.dialog pkgs.coreutils @@ -25,7 +18,7 @@ let config.programs.mbsync.package config.programs.notmuch.package ]; - inherit config; + text = builtins.readFile ./neomutt-sync.sh; }; in { @@ -35,7 +28,6 @@ in ./assertions.nix ./keybindings.nix ./macros.nix - ./neomutt.nix ]; options.communication.neomutt = { @@ -47,23 +39,65 @@ in default = config.programs.neomutt.package; description = "The neomutt package to use, wrapped with urlscan in PATH."; }; - } - // neomuttSync.options.communication.neomutt; + }; - config = lib.mkMerge [ - (lib.mkIf config.communication.neomutt.enable { - accounts.email.maildirBasePath = "${config.home.homeDirectory}/.local/share/mail"; - home.sessionVariables.MAILDIR = config.accounts.email.maildirBasePath; - }) - neomuttSync.config - { - assertions = [ - { - assertion = - !config.communication.neomutt.neomutt-sync.enable || config.communication.neomutt.enable; - message = "communication.neomutt.neomutt-sync is enabled but requires `communication.neomutt.enable`."; - } + config = lib.mkIf config.communication.neomutt.enable { + accounts.email.maildirBasePath = "${config.home.homeDirectory}/.local/share/mail"; + home.sessionVariables.MAILDIR = config.accounts.email.maildirBasePath; + + xdg.desktopEntries."neomutt" = { + name = "NeoMutt"; + exec = "${lib.getExe config.terminal.kitty.package} --class neomutt -e ${lib.getExe config.programs.neomutt.package}"; + icon = "${config.programs.neomutt.package}/share/neomutt/logo/neomutt.svg"; + categories = [ + "Network" + "Email" ]; - } - ]; + comment = "Terminal email client"; + terminal = false; + type = "Application"; + }; + xdg.mimeApps.defaultApplications = { + "x-scheme-handler/mailto" = "neomutt.desktop"; + }; + xdg.configFile."neomutt/mailcap".text = '' + text/html; ${lib.getExe config.web.chawan.package} -o "title='neomutt'" '%s'; nametemplate=%s.html + image/*; xdg-open '%s' & + application/pdf; xdg-open '%s'; nametemplate=%s.pdf + video/*; xdg-open '%s' & + audio/*; xdg-open '%s' & + application/*; xdg-open '%s' & + ''; + programs.neomutt = { + enable = true; + package = pkgs.symlinkJoin { + name = "neomutt-wrapped"; + paths = [ + pkgs.neomutt + neomuttSyncScript + ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/neomutt \ + --prefix PATH : ${config.home.profileDirectory}/bin:${lib.makeBinPath [ pkgs.urlscan ]} + ''; + meta.mainProgram = "neomutt"; + }; + sidebar.enable = true; + sort = "reverse-threads"; + vimKeys = false; + unmailboxes = true; + checkStatsInterval = 20; + extraConfig = '' + # Read messages in Neovim. `-` makes Neovim read the message from + # stdin and -R prevents accidental edits to message content. + set pager = "${lib.getExe config.development.nixvim.package} -R -n +'setlocal nolist | silent! 1,2g/^$/delete _ | nohlsearch | setlocal nomodified nomodifiable' -" + # Return directly to the index when Neovim exits and do not prepend + # NeoMutt’s pager status line to the message passed to Neovim. + set noprompt_after + set pager_format = "" + '' + + builtins.readFile ./.neomuttrc; + }; + }; } |
