Merge pull request #95722 from Infinisil/dovecot-mailboxes-improved
nixos/dovecot: Improve mailboxes type
This commit is contained in:
commit
bf777413f9
@ -1,4 +1,4 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ options, config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
@ -83,11 +83,11 @@ let
|
||||
)
|
||||
|
||||
(
|
||||
optionalString (cfg.mailboxes != []) ''
|
||||
optionalString (cfg.mailboxes != {}) ''
|
||||
protocol imap {
|
||||
namespace inbox {
|
||||
inbox=yes
|
||||
${concatStringsSep "\n" (map mailboxConfig cfg.mailboxes)}
|
||||
${concatStringsSep "\n" (map mailboxConfig (attrValues cfg.mailboxes))}
|
||||
}
|
||||
}
|
||||
''
|
||||
@ -131,12 +131,13 @@ let
|
||||
special_use = \${toString mailbox.specialUse}
|
||||
'' + "}";
|
||||
|
||||
mailboxes = { ... }: {
|
||||
mailboxes = { name, ... }: {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = types.nullOr (types.strMatching ''[^"]+'');
|
||||
type = types.strMatching ''[^"]+'';
|
||||
example = "Spam";
|
||||
default = null;
|
||||
default = name;
|
||||
readOnly = true;
|
||||
description = "The name of the mailbox.";
|
||||
};
|
||||
auto = mkOption {
|
||||
@ -335,19 +336,11 @@ in
|
||||
};
|
||||
|
||||
mailboxes = mkOption {
|
||||
type = with types; let m = submodule mailboxes; in either (listOf m) (attrsOf m);
|
||||
type = with types; coercedTo
|
||||
(listOf unspecified)
|
||||
(list: listToAttrs (map (entry: { name = entry.name; value = removeAttrs entry ["name"]; }) list))
|
||||
(attrsOf (submodule mailboxes));
|
||||
default = {};
|
||||
apply = x:
|
||||
if isList x then warn "Declaring `services.dovecot2.mailboxes' as a list is deprecated and will break eval in 21.03!" x
|
||||
else mapAttrsToList (name: value:
|
||||
if value.name != null
|
||||
then throw ''
|
||||
When specifying dovecot2 mailboxes as attributes, declaring
|
||||
a `name'-attribute is prohibited! The name ${value.name} should
|
||||
be the attribute key!
|
||||
''
|
||||
else value // { inherit name; }
|
||||
) x;
|
||||
example = literalExample ''
|
||||
{
|
||||
Spam = { specialUse = "Junk"; auto = "create"; };
|
||||
@ -471,6 +464,10 @@ in
|
||||
|
||||
environment.systemPackages = [ dovecotPkg ];
|
||||
|
||||
warnings = mkIf (any isList options.services.dovecot2.mailboxes.definitions) [
|
||||
"Declaring `services.dovecot2.mailboxes' as a list is deprecated and will break eval in 21.03! See the release notes for more info for migration."
|
||||
];
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = intersectLists cfg.protocols [ "pop3" "imap" ] != [];
|
||||
|
Loading…
Reference in New Issue
Block a user