From c2ca4d1bb05a5c3886b433dc10b2c4d55bfa1f29 Mon Sep 17 00:00:00 2001
From: Michishige Kaito <me@mkaito.com>
Date: Fri, 23 Nov 2018 14:29:23 +0000
Subject: [PATCH] postfix: allow configuring message_size_limit

---
 default.nix             | 7 +++++++
 mail-server/postfix.nix | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/default.nix b/default.nix
index db68f2e..58ab271 100644
--- a/default.nix
+++ b/default.nix
@@ -39,6 +39,13 @@ in
       description = "The domains that this mail server serves.";
     };
 
+    messageSizeLimit = mkOption {
+      type = types.int;
+      example = 52428800;
+      default = 20971520;
+      description = "Message size limit enforced by Postfix.";
+    };
+
     loginAccounts = mkOption {
       type = types.loaOf (types.submodule ({ name, ... }: {
         options = {
diff --git a/mail-server/postfix.nix b/mail-server/postfix.nix
index cea787f..9ad668a 100644
--- a/mail-server/postfix.nix
+++ b/mail-server/postfix.nix
@@ -76,7 +76,7 @@ let
   # see
   # https://blog.grimneko.de/2011/12/24/a-bunch-of-tips-for-improving-your-postfix-setup/
   # for details on how this file looks. By using the same file as valiases,
-  # every alias is owned (uniquely) by its user. 
+  # every alias is owned (uniquely) by its user.
   # The user's own address is already in all_valiases_postfix.
   vaccounts_file = builtins.toFile "vaccounts" (lib.concatStringsSep "\n" all_valiases_postfix);
 
@@ -135,7 +135,7 @@ in
 
         smtpd_banner = ${fqdn} ESMTP NO UCE
         disable_vrfy_command = yes
-        message_size_limit = 20971520
+        message_size_limit = ${builtins.toString cfg.messageSizeLimit}
 
         # virtual mail system
         virtual_uid_maps = static:5000