diff options
| author | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-24 19:16:14 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-24 19:16:14 +0530 |
| commit | f36491c92269d3e1dd241e67c292af762ac498c3 (patch) | |
| tree | 7e36c45915bf83dc7b69e21830cf0c27397c0592 /modules/communication | |
| parent | f85b86095aa4ea6ac4921b6d37981bffa5c0b711 (diff) | |
| download | home-manager-config-f36491c92269d3e1dd241e67c292af762ac498c3.tar.gz home-manager-config-f36491c92269d3e1dd241e67c292af762ac498c3.zip | |
refactor: some more minor refactoring
Diffstat (limited to 'modules/communication')
| -rw-r--r-- | modules/communication/neomutt/account/assertions.nix | 13 | ||||
| -rw-r--r-- | modules/communication/neomutt/account/default.nix | 7 | ||||
| -rw-r--r-- | modules/communication/neomutt/assertions.nix | 11 | ||||
| -rw-r--r-- | modules/communication/neomutt/default.nix | 2 | ||||
| -rw-r--r-- | modules/communication/neomutt/keybindings.nix | 3 | ||||
| -rw-r--r-- | modules/communication/neomutt/macros.nix | 5 | ||||
| -rw-r--r-- | modules/communication/neomutt/mail/mbsync.nix | 4 | ||||
| -rw-r--r-- | modules/communication/neomutt/mail/notmuch.nix | 5 | ||||
| -rw-r--r-- | modules/communication/senpai/assertions.nix | 12 |
9 files changed, 39 insertions, 23 deletions
diff --git a/modules/communication/neomutt/account/assertions.nix b/modules/communication/neomutt/account/assertions.nix index 5c30311..09839c8 100644 --- a/modules/communication/neomutt/account/assertions.nix +++ b/modules/communication/neomutt/account/assertions.nix @@ -1,12 +1,15 @@ # Validates the neomutt account configurations { config, lib, ... }: +let + cfg = config.communication.neomutt; +in { config.assertions = [ { assertion = - !config.communication.neomutt.enable + !cfg.enable || !lib.any (account: account.enable && account.password-gopass-secret != null) ( - lib.attrValues config.communication.neomutt.accounts + lib.attrValues cfg.accounts ) || config.security.gopass.enable; message = '' @@ -16,10 +19,8 @@ } { assertion = - !config.communication.neomutt.enable - || !lib.any (account: account.enable && account.gpg.key != null) ( - lib.attrValues config.communication.neomutt.accounts - ) + !cfg.enable + || !lib.any (account: account.enable && account.gpg.key != null) (lib.attrValues cfg.accounts) || config.security.gpg.enable; message = '' An enabled communication.neomutt account specifies a GPG key but security.gpg.enable is not set. diff --git a/modules/communication/neomutt/account/default.nix b/modules/communication/neomutt/account/default.nix index 61256e1..07a4b89 100644 --- a/modules/communication/neomutt/account/default.nix +++ b/modules/communication/neomutt/account/default.nix @@ -1,5 +1,8 @@ # Converts neomutt account options into home-manager email config { config, lib, ... }: +let + cfg = config.communication.neomutt; +in { imports = [ ./assertions.nix @@ -19,7 +22,7 @@ description = "Specification of email accounts."; }; - config = lib.mkIf config.communication.neomutt.enable { + config = lib.mkIf cfg.enable { accounts.email.accounts = lib.mapAttrs (accountName: accountInformation: { inherit (accountInformation) address primary; @@ -109,6 +112,6 @@ command = accountInformation.signature.command; showSignature = accountInformation.signature.show-signature; }; - }) (lib.filterAttrs (n: a: a.enable) config.communication.neomutt.accounts); + }) (lib.filterAttrs (n: a: a.enable) cfg.accounts); }; } diff --git a/modules/communication/neomutt/assertions.nix b/modules/communication/neomutt/assertions.nix index e8351f0..cddc7bf 100644 --- a/modules/communication/neomutt/assertions.nix +++ b/modules/communication/neomutt/assertions.nix @@ -1,30 +1,33 @@ # Validates NeoMutt dependencies. { config, ... }: +let + cfg = config.communication.neomutt; +in { assertions = [ { - assertion = !config.communication.neomutt.enable || config.development.nixvim.enable; + assertion = !cfg.enable || config.development.nixvim.enable; message = '' communication.neomutt is enabled but development.nixvim.enable is not. neomutt uses Neovim as its external pager. Please enable development.nixvim. ''; } { - assertion = !config.communication.neomutt.enable || config.terminal.bat.enable; + assertion = !cfg.enable || config.terminal.bat.enable; message = '' communication.neomutt is enabled but terminal.bat.enable is not. neomutt requires bat for text/html filtering. Please enable terminal.bat. ''; } { - assertion = !config.communication.neomutt.enable || config.terminal.kitty.enable; + assertion = !cfg.enable || config.terminal.kitty.enable; message = '' communication.neomutt is enabled but terminal.kitty.enable is not. neomutt's desktop entry requires kitty as the terminal launcher. Please enable terminal.kitty. ''; } { - assertion = !config.communication.neomutt.enable || config.web.chawan.enable; + assertion = !cfg.enable || config.web.chawan.enable; message = '' communication.neomutt is enabled but web.chawan.enable is not. neomutt uses chawan for HTML email rendering. Please enable web.chawan. diff --git a/modules/communication/neomutt/default.nix b/modules/communication/neomutt/default.nix index 6bc363b..365ef32 100644 --- a/modules/communication/neomutt/default.nix +++ b/modules/communication/neomutt/default.nix @@ -11,7 +11,7 @@ let 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 + lib.filterAttrs (name: account: account.enable) cfg.accounts ); neomuttSyncScript = pkgs.writeShellApplication { diff --git a/modules/communication/neomutt/keybindings.nix b/modules/communication/neomutt/keybindings.nix index 80e33cd..3bfb137 100644 --- a/modules/communication/neomutt/keybindings.nix +++ b/modules/communication/neomutt/keybindings.nix @@ -2,13 +2,14 @@ { config, lib, ... }: let + cfg = config.communication.neomutt; bind = keyMap: key: action: { map = keyMap; inherit key action; }; in { - config.programs.neomutt.binds = lib.mkIf config.communication.neomutt.enable [ + config.programs.neomutt.binds = lib.mkIf cfg.enable [ # Index (bind [ "index" ] "$" "noop") (bind [ "index" ] "g" "noop") diff --git a/modules/communication/neomutt/macros.nix b/modules/communication/neomutt/macros.nix index 4e5bf7b..d4abf28 100644 --- a/modules/communication/neomutt/macros.nix +++ b/modules/communication/neomutt/macros.nix @@ -1,7 +1,10 @@ # neomutt macros for sync, URL extraction, flag legend, and quit { config, lib, ... }: +let + cfg = config.communication.neomutt; +in { - config.programs.neomutt.macros = lib.mkIf config.communication.neomutt.enable [ + config.programs.neomutt.macros = lib.mkIf cfg.enable [ { map = [ "index" diff --git a/modules/communication/neomutt/mail/mbsync.nix b/modules/communication/neomutt/mail/mbsync.nix index f586538..b93b134 100644 --- a/modules/communication/neomutt/mail/mbsync.nix +++ b/modules/communication/neomutt/mail/mbsync.nix @@ -5,6 +5,8 @@ ... }: let + cfg = config.communication.neomutt; + mbsyncNamesFromName = (import ../lib.nix { inherit lib; }).mbsyncNamesFromName; mbsyncValue = @@ -93,7 +95,7 @@ let ); in { - config = lib.mkIf config.communication.neomutt.enable { + config = lib.mkIf cfg.enable { programs.mbsync.enable = true; xdg.configFile."mbsync/.mbsyncrc".text = lib.concatStringsSep "\n" (map mbsyncAccount accounts); diff --git a/modules/communication/neomutt/mail/notmuch.nix b/modules/communication/neomutt/mail/notmuch.nix index 6f806fb..80b6bd1 100644 --- a/modules/communication/neomutt/mail/notmuch.nix +++ b/modules/communication/neomutt/mail/notmuch.nix @@ -1,7 +1,10 @@ # Mail indexer for fast email search { config, lib, ... }: +let + cfg = config.communication.neomutt; +in { - config = lib.mkIf config.communication.neomutt.enable { + config = lib.mkIf cfg.enable { programs.notmuch.enable = true; }; } diff --git a/modules/communication/senpai/assertions.nix b/modules/communication/senpai/assertions.nix index 8e74367..0f0a3dc 100644 --- a/modules/communication/senpai/assertions.nix +++ b/modules/communication/senpai/assertions.nix @@ -1,20 +1,20 @@ # Validates Senpai dependencies. { config, ... }: +let + cfg = config.communication.senpai; +in { assertions = [ { - assertion = !config.communication.senpai.enable || config.communication.senpai.server.address != ""; + assertion = !cfg.enable || cfg.server.address != ""; message = "communication.senpai.enable requires communication.senpai.server.address to be set."; } { - assertion = - !config.communication.senpai.enable || config.communication.senpai.identity.nickname != ""; + assertion = !cfg.enable || cfg.identity.nickname != ""; message = "communication.senpai.enable requires communication.senpai.identity.nickname to be set."; } { - assertion = - config.communication.senpai.identity.password-gopass-secret == null - || config.security.gopass.enable; + assertion = cfg.identity.password-gopass-secret == null || config.security.gopass.enable; message = "communication.senpai.identity.password-gopass-secret requires security.gopass.enable."; } ]; |
