]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/tools/mail/mta-sts.nix
Add specification for the private config file as a module.
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / mail / mta-sts.nix
index bedefdaf8643b0c63b14ec445f8704f21cc442c3..a401b41fdf3f31c05ba99032caef3255c9546297 100644 (file)
@@ -1,4 +1,4 @@
-{ lib, pkgs, config, myconfig,  ... }:
+{ lib, pkgs, config,  ... }:
 let
   domains = (lib.remove null (lib.flatten (map
     (zone: map
@@ -11,7 +11,7 @@ let
       )
       (zone.withEmail or [])
     )
-    myconfig.env.dns.masterZones
+    config.myEnv.dns.masterZones
   )));
   # FIXME: increase the id number in modules/private/dns.nix when this
   # file change (date -u +'%Y%m%d%H%M%S'Z)
@@ -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>
+        ''
+      ];
+    };
   };
-
 }