]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/tools/mail/mta-sts.nix
Add new machine to nixops
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / mail / mta-sts.nix
index bedefdaf8643b0c63b14ec445f8704f21cc442c3..d443f55115710f8573ff326795605e0fedded54e 100644 (file)
@@ -28,28 +28,30 @@ let
       "cp ${file d} $out/${d.domain}.txt"
     ) domains)}
     '';
+  cfg = config.myServices.websites.tools.email;
 in
 {
-  config.myServices.websites.webappDirs = {
-    _mta-sts = root;
-  };
+  config = lib.mkIf cfg.enable {
+    myServices.websites.webappDirs = {
+      _mta-sts = root;
+    };
 
-  config.services.websites.env.tools.vhostConfs.mta_sts = {
-    certName   = "mail";
-    addToCerts = true;
-    hosts = ["mta-sts.mail.immae.eu"] ++ map (v: "mta-sts.${v.domain}") domains;
-    root = "/run/current-system/webapps/_mta-sts";
-    extraConfig = [
-      ''
-        RewriteEngine on
-        RewriteCond %{HTTP_HOST} ^mta-sts.(.*)$
-        RewriteRule ^/.well-known/mta-sts.txt$ %{DOCUMENT_ROOT}/%1.txt [L]
-        <Directory /run/current-system/webapps/_mta-sts>
-          Require all granted
-          Options -Indexes
-        </Directory>
-      ''
-    ];
+    services.websites.env.tools.vhostConfs.mta_sts = {
+      certName   = "mail";
+      addToCerts = true;
+      hosts = ["mta-sts.mail.immae.eu"] ++ map (v: "mta-sts.${v.domain}") domains;
+      root = "/run/current-system/webapps/_mta-sts";
+      extraConfig = [
+        ''
+          RewriteEngine on
+          RewriteCond %{HTTP_HOST} ^mta-sts.(.*)$
+          RewriteRule ^/.well-known/mta-sts.txt$ %{DOCUMENT_ROOT}/%1.txt [L]
+          <Directory /run/current-system/webapps/_mta-sts>
+            Require all granted
+            Options -Indexes
+          </Directory>
+        ''
+      ];
+    };
   };
-
 }