programs.neomutt: Fix eval error when primary account not enabled (#1873)
* neomutt: Fix eval error when primary account not enabled If neomutt is enabled for an account, but not the primary account, the configuration will fail with "list index 0 is out of bounds". This adds the first neomutt-enabled account as a fallback. * neomutt: add regression test/update tests
This commit is contained in:
parent
c1761366b5
commit
cbf0667037
5 changed files with 77 additions and 5 deletions
|
|
@ -279,7 +279,11 @@ in {
|
|||
in foldl' (a: b: a // b) { } (map rcFile neomuttAccounts);
|
||||
|
||||
xdg.configFile."neomutt/neomuttrc" = mkIf (neomuttAccounts != [ ]) {
|
||||
text = let primary = filter (a: a.primary) neomuttAccounts;
|
||||
text = let
|
||||
# Find the primary account, if it has neomutt enabled;
|
||||
# otherwise use the first neomutt account as primary.
|
||||
primary =
|
||||
head (filter (a: a.primary) neomuttAccounts ++ neomuttAccounts);
|
||||
in ''
|
||||
# Generated by Home Manager.
|
||||
set header_cache = "${config.xdg.cacheHome}/neomutt/headers/"
|
||||
|
|
@ -304,9 +308,13 @@ in {
|
|||
${optionsStr cfg.settings}
|
||||
|
||||
${cfg.extraConfig}
|
||||
'' + concatMapStringsSep "\n" registerAccount neomuttAccounts +
|
||||
# source primary account
|
||||
"source ${accountFilename (builtins.head primary)}";
|
||||
|
||||
# Register accounts
|
||||
${concatMapStringsSep "\n" registerAccount neomuttAccounts}
|
||||
|
||||
# Source primary account
|
||||
source ${accountFilename primary}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue