neomutt: Allow named mailboxes (#2212)
At the moment, only the inbox of each mail account is added to neomutt. This inbox is always called "Inbox", so if you configure multiple accounts, it is hard to know which one is which. This change allows the user to specify a display name per account that uses `named-mailboxes` under the hood. Additionally this change now allows to add other folders than the inbox, for example the Trash, Spam or Drafts folders to be added on a per-account basis. Using extraOptions is not possible here, as those are lazily loaded on mailbox open and thus would appear at the bottom and not sorted by account. This commit also changes the default sidebar format string to use %D instead of %B because %B will ignore named mailboxes and show the folder name instead.
This commit is contained in:
parent
1a6df903e3
commit
bf6b85136b
8 changed files with 140 additions and 5 deletions
|
|
@ -2,7 +2,25 @@
|
|||
|
||||
with lib;
|
||||
|
||||
{
|
||||
let
|
||||
extraMailboxOptions = {
|
||||
options = {
|
||||
mailbox = mkOption {
|
||||
type = types.str;
|
||||
example = "Sent";
|
||||
description = "Name of mailbox folder to be included";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
example = "Junk";
|
||||
default = null;
|
||||
description = "Name to display";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
options.neomutt = {
|
||||
enable = mkEnableOption "NeoMutt";
|
||||
|
||||
|
|
@ -32,5 +50,18 @@ with lib;
|
|||
Extra lines to add to the folder hook for this account.
|
||||
'';
|
||||
};
|
||||
|
||||
mailboxName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "==== <mailbox-name> ===";
|
||||
description = "Use a different name as mailbox name";
|
||||
};
|
||||
|
||||
extraMailboxes = mkOption {
|
||||
type = with types; listOf (either str (submodule extraMailboxOptions));
|
||||
default = [ ];
|
||||
description = "List of extra mailboxes";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ let
|
|||
|
||||
format = mkOption {
|
||||
type = types.str;
|
||||
default = "%B%?F? [%F]?%* %?N?%N/?%S";
|
||||
default = "%D%?F? [%F]?%* %?N?%N/?%S";
|
||||
description = ''
|
||||
Sidebar format. Check neomutt documentation for details.
|
||||
'';
|
||||
|
|
@ -133,10 +133,25 @@ let
|
|||
'';
|
||||
|
||||
registerAccount = account:
|
||||
with account; ''
|
||||
let
|
||||
mailboxes = if account.neomutt.mailboxName == null then
|
||||
"mailboxes"
|
||||
else
|
||||
''named-mailboxes "${account.neomutt.mailboxName}"'';
|
||||
extraMailboxes = concatMapStringsSep "\n" (extra:
|
||||
if isString extra then
|
||||
''mailboxes "${account.maildir.absPath}/${extra}"''
|
||||
else if extra.name == null then
|
||||
''mailboxes "${account.maildir.absPath}/${extra.mailbox}"''
|
||||
else
|
||||
''
|
||||
named-mailboxes "${extra.name}" "${account.maildir.absPath}/${extra.mailbox}"'')
|
||||
account.neomutt.extraMailboxes;
|
||||
in with account; ''
|
||||
# register account ${name}
|
||||
mailboxes "${account.maildir.absPath}/${folders.inbox}"
|
||||
folder-hook ${account.maildir.absPath}/ " \
|
||||
${mailboxes} "${maildir.absPath}/${folders.inbox}"
|
||||
${extraMailboxes}
|
||||
folder-hook ${maildir.absPath}/ " \
|
||||
source ${accountFilename account} "
|
||||
'';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue