anchor.diff:        }
       '')
   
  +    ''
  +      protocol imap {
  +        namespace inbox {
  +          inbox=yes
  +          ${concatStringsSep "\n" (map mailboxConfig cfg.mailboxes)}
  +        }
  +      }
  +    ''
  +
  +    (optionalString cfg.enableQuota ''
  +      mail_plugins = $mail_plugins quota
  +      service quota-status {
  +        executable = ${dovecotPkg}/libexec/dovecot/quota-status -p postfix
  +        inet_listener {
  +          port = ${cfg.quotaPort}
  +        }
  +        client_limit = 1
  +      }
  +
  +      protocol imap {
  +        mail_plugins = $mail_plugins imap_quota
  +      }
  +
  +      plugin {
  +        quota_rule = *:storage=${cfg.quotaGlobalPerUser} 
  +        quota = maildir:User quota # per virtual mail user quota # BUG/FIXME broken, we couldn't get this working
  +        quota_status_success = DUNNO
  +        quota_status_nouser = DUNNO
  +        quota_status_overquota = "552 5.2.2 Mailbox is full"
  +        quota_grace = 10%%
  +      }
  +    '')
  +
       cfg.extraConfig
     ];
   
  
positive.code: 
      enablePop3 = mkOption {
        type = types.bool;
        default = true;
        description = "Start the POP3 listener (when Dovecot is enabled).";
      };
  
  
negative.code:     paths = map (pkg: "${pkg}/lib/dovecot") ([ dovecotPkg ] ++ map (module: module.override { dovecot = dovecotPkg; }) cfg.modules);
    };
  
    mailboxConfig = mailbox: ''
      mailbox ${mailbox.name} {
        auto = ${toString mailbox.auto}
    '' + optionalString (mailbox.specialUse != null) ''
        special_use = \${toString mailbox.specialUse}
    '' + "}";
  
    mailboxes = { lib, pkgs, ... }: {
      options = {
        name = mkOption {
          type = types.str;
          example = "Spam";
          description = "The name of the mailbox.";
        };
        auto = mkOption {
          type = types.enum [ "no" "create" "subscribe" ];
          default = "no";
          example = "subscribe";
          description = "Whether to automatically create or create and subscribe to the mailbox or not.";
        };
        specialUse = mkOption {
          type = types.nullOr (types.enum [ "All" "Archive" "Drafts" "Flagged" "Junk" "Sent" "Trash" ]);
          default = null;
          example = "Junk";
          description = "Null if no special use flag is set. Other than that every use flag mentioned in the RFC is valid.";
        };
      };
    };
  in
  {
  
  