nix: remove networking.domainAliases
authorJulien Moutinho <julm@sourcephile.fr>
Wed, 11 Mar 2020 19:12:23 +0000 (20:12 +0100)
committerJulien Moutinho <julm@sourcephile.fr>
Wed, 11 Mar 2020 19:12:23 +0000 (20:12 +0100)
nixos/modules/services/mail/dovecot.nix
nixos/modules/services/networking/domains.nix
servers/mermet/nginx/sourcephile.fr/git.nix

index d33aa05ec1fd743f91b5b534c365af6370e896f7..a4c693a9827b3306487957eef95badd8e73c223c 100644 (file)
@@ -1,83 +1,19 @@
 { pkgs, lib, config, ... }:
 let
-  inherit (builtins) toString toFile attrNames;
-  inherit (lib) types;
-  inherit (pkgs.lib) unlinesAttrs unlinesValues unwords;
-  inherit (config.services) dovecot2 openldap;
-  inherit (config) networking;
+  inherit (pkgs.lib) unlinesValues;
+  inherit (config.services) dovecot2;
   stateDir = "/var/lib/dovecot";
-  escapeGroup = lib.stringAsChars (c: if "a"<=c && c<="z"
-                                      || "0"<=c && c<="9"
-                                      || c=="-"
-                                      then c else "_");
-  domainGroup = escapeGroup "${networking.domainBase}";
 in
 {
-options.services.dovecot2 = {
-  domains = lib.mkOption {
-    default = {};
-    type    = types.attrsOf (types.submodule ({domain, ...}: {
-      #config.domain = lib.mkDefault domain;
-      options = {
-        accounts = lib.mkOption {
-          type = types.attrsOf (types.submodule ({account, ...}: {
-            options = {
-              password = lib.mkOption {
-                type        = types.str;
-                example     = "{SSHA512}uyjL1KYx4z7HpfNvnKzuVxpMLD2KVueGGBvOcj7AF1EZCTVhT++IIKUVOC4xpZtWdqVD0OVmZqgYr2qpn/3t3Aj4oU0=";
-                description = ''Password.
-                Use: `doveadm pw -s SSHA512 -p "$password"`
-                '';
-              };
-              aliases = lib.mkOption {
-                type        = with types; listOf types.str;
-                example     = [ "abuse@${config.networking.domain}" ];
-                default     = [];
-                description = ''Aliases of this account.'';
-              };
-              quota = lib.mkOption {
-                type        = with types; nullOr types.str;
-                default     = null;
-                example     = "2G";
-                description = ''
-                  Per user quota rules. Accepted sizes are `xx k/M/G/T` with the
-                  obvious meaning. Leave blank for the standard quota `100G`.
-                '';
-              };
-              groups = lib.mkOption {
-                type    = with types; listOf str;
-                default = [];
-              };
-            };
-          }));
-        };
-      };
-    }));
-  };
-};
-
 config = lib.mkIf dovecot2.enable {
   systemd.services.dovecot2 = {
     preStart = unlinesValues {
-      installDomains =
-        lib.optionalString openldap.enable ''
-          # NOTE: make sure nslcd cache is in sync with the LDAP data
-          systemctl restart nslcd
-        '' + ''
+      installDomains = ''
         # SEE: http://wiki2.dovecot.org/SharedMailboxes/Permissions
         install -D -d -m 0771 \
          -o "${dovecot2.user}" \
          -g "${dovecot2.group}" \
          ${stateDir}/mail
-
-        # NOTE: domainAliases point to the very same mailboxes as domain's.
-        for domainAlias in ${unwords networking.domainAliases}
-         do
-          ln -fns ${networking.domain} ${stateDir}/mail/$domainAlias
-          ln -fns ${networking.domain} ${stateDir}/control/$domainAlias
-          ln -fns ${networking.domain} ${stateDir}/index/$domainAlias
-          ln -fns ${networking.domain} ${stateDir}/acl/$domainAlias
-         done
       '';
     };
   };
index be3f6bf13e6fc3da247b826f434dcdeee4bc2e40..a784c2da514b23641df1183c83601e11cd74a511 100644 (file)
@@ -7,11 +7,5 @@ options.networking = {
     description = "Base network name.";
     example     = "example";
   };
-  domainAliases = lib.mkOption {
-    type        = types.listOf types.str;
-    description = "Domain aliases.";
-    default     = [];
-    example     = [ "example.org" "example.net" ];
-  };
 };
 }
index 52eae4ae945b8d2bfc819cfea2ced5a380d912db..001e923c67bf2d02ef937ae3e8340743d332e746 100644 (file)
@@ -21,9 +21,6 @@ in
   services.nginx = {
     virtualHosts."git" = {
       serverName = "git.${domain}";
-      serverAliases =
-        map (domainAlias: "git." + domainAlias)
-            config.networking.domainAliases;
       forceSSL = true;
       useACMEHost = domain;
       locations = {