anchor.diff:        default = "";
         example = "mail_debug = yes";
         description = "Additional entries to put verbatim into Dovecot's config file.";
  +    };
  +
  +    mailPlugins =
  +    let plugins = hint: types.submodule {
  +        options = {
  +          enable = mkOption {
  +            type = types.listOf types.str;
  +            default = [];
  +            description = "mail plugins to enable as a list of strings to append to the ${hint} <literal>$mail_plugins</literal> configuration variable";
  +          };
  +        };
  +      };
  +    in
  +    mkOption {
  +      type = with types; submodule {
  +        options = {
  +          globally = mkOption {
  +            type = plugins "top-level";
  +            example = { enable =[ "virtual" ]; };
  +            default = { enable = []; };
  +          };
  +          perProtocol = mkOption {
  +            type = attrsOf (plugins "corresponding per-protocol");
  +            default = {};
  +            example = { imap = [ "imap_acl" ]; };
  +          };
  +        };
  +      };
  +      description = "Additional entries to add to the mail_plugins variable, globally and per protocol";
  +      example = {
  +        globally.enable = [ "acl" ];
  +        perProtocol.imap.enable = [ "imap_acl" ];
  +      };
  +      default = { globally.enable = []; perProtocol = {};};
       };
   
       configFile = mkOption {
  
positive.code:       base_dir = ${baseDir}
        protocols = ${concatStringsSep " " cfg.protocols}
        sendmail_path = /run/wrappers/bin/sendmail
      ''
  
      (if cfg.sslServerCert == null then ''
        ssl = no
  
negative.code:      optional cfg.enableImap "imap"
       ++ optional cfg.enablePop3 "pop3"
       ++ optional cfg.enableLmtp "lmtp";
  
      services.dovecot2.mailPlugins = mkIf cfg.enableQuota {
        globally.enable = [ "quota" ];
        perProtocol.imap.enable = [ "imap_quota" ];
      };
  
      users.users = {
        dovenull =
  