diff --git a/modules/programs/neomutt/default.nix b/modules/programs/neomutt/default.nix index 29da7c800..d961712ec 100644 --- a/modules/programs/neomutt/default.nix +++ b/modules/programs/neomutt/default.nix @@ -10,6 +10,7 @@ let concatStringsSep concatMapStringsSep filter + filterAttrs isString mkIf mkOption @@ -19,22 +20,20 @@ let cfg = config.programs.neomutt; - neomuttAccounts = filter (a: a.neomutt.enable) (attrValues config.accounts.email.accounts); + neomuttAccountsCfg = filterAttrs (n: a: a.neomutt.enable) config.accounts.email.accounts; + neomuttAccounts = attrValues neomuttAccountsCfg; accountCommandNeeded = lib.any ( a: - a.neomutt.enable - && ( - a.neomutt.mailboxType == "imap" - || (lib.any (m: !isString m && m.type == "imap") a.neomutt.extraMailboxes) - ) - ) (attrValues config.accounts.email.accounts); + a.neomutt.mailboxType == "imap" + || (lib.any (m: !isString m && m.type == "imap") a.neomutt.extraMailboxes) + ) neomuttAccounts; accountCommand = let imapAccounts = filter ( - a: a.neomutt.enable && a.imap.host != null && a.userName != null && a.passwordCommand != null - ) (attrValues config.accounts.email.accounts); + a: a.imap.host != null && a.userName != null && a.passwordCommand != null + ) neomuttAccounts; accountCase = account: let @@ -538,12 +537,17 @@ in ); }; - assertions = [ - { - assertion = ((filter (b: (lib.length (lib.toList b.map)) == 0) (cfg.binds ++ cfg.macros)) == [ ]); - message = "The 'programs.neomutt.(binds|macros).map' list must contain at least one element."; - } - ]; + assertions = + [ + { + assertion = ((filter (b: (lib.length (lib.toList b.map)) == 0) (cfg.binds ++ cfg.macros)) == [ ]); + message = "The 'programs.neomutt.(binds|macros).map' list must contain at least one element."; + } + ] + ++ lib.mapAttrsToList (n: a: { + assertion = a.neomutt.sendMailCommand != null || a.passwordCommand != null; + message = "'accounts.email.accounts.${n}' needs either 'neomutt.sendMailCommand' or 'passwordCommand' set."; + }) neomuttAccountsCfg; warnings = let