diff --git a/default.nix b/default.nix index a2158a6..5b5e015 100644 --- a/default.nix +++ b/default.nix @@ -172,7 +172,7 @@ in ''; }; - cert_dir = mkOption { + certificateDirectory = mkOption { type = types.path; default = "/var/certs"; description = '' @@ -183,7 +183,7 @@ in ''; }; - enable_imap = mkOption { + enableImap = mkOption { type = types.bool; default = true; description = '' @@ -196,7 +196,7 @@ in ''; }; - enable_pop3 = mkOption { + enablePop3 = mkOption { type = types.bool; default = false; description = '' @@ -221,7 +221,7 @@ in ''; }; - dkim_signing = mkOption { + dkimSigning = mkOption { type = types.bool; default = true; description = '' @@ -230,7 +230,7 @@ in ''; }; - dkim_selector = mkOption { + dkimSelector = mkOption { type = types.string; default = "mail"; description = '' @@ -238,7 +238,7 @@ in ''; }; - dkim_dir = mkOption { + dkimKeyDirectory = mkOption { type = types.path; default = "/var/dkim"; description = '' @@ -255,8 +255,8 @@ in services = import ./mail-server/services.nix { inherit lib; inherit (cfg) mailDirectory vmailUserName vmailGroupName virtualAliases domain - enable_imap enable_pop3 dkim_signing dkim_selector dkim_dir - certificateScheme certificateFile keyFile cert_dir virusScanning; + enableImap enablePop3 dkimSigning dkimSelector dkimKeyDirectory + certificateScheme certificateFile keyFile certificateDirectory virusScanning; }; environment = import ./mail-server/environment.nix { @@ -265,13 +265,14 @@ in }; networking = import ./mail-server/networking.nix { - inherit (cfg) domain hostPrefix enable_imap enable_pop3; + inherit (cfg) domain hostPrefix enableImap enablePop3; }; systemd = import ./mail-server/systemd.nix { inherit pkgs; - inherit (cfg) mailDirectory vmailGroupName certificateScheme cert_dir - hostPrefix domain dkim_selector dkim_dir; + inherit (cfg) mailDirectory vmailGroupName certificateScheme + certificateDirectory + hostPrefix domain dkimSelector dkimKeyDirectory; }; users = import ./mail-server/users.nix { diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index d94539e..15d08ee 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ vmailGroupName, vmailUserName, mailDirectory, enable_imap, enable_pop3, cert, +{ vmailGroupName, vmailUserName, mailDirectory, enableImap, enablePop3, cert, key }: let @@ -24,8 +24,8 @@ let in { enable = true; - enableImap = enable_imap; - enablePop3 = enable_pop3; + enableImap = enableImap; + enablePop3 = enablePop3; mailGroup = vmailGroupName; mailUser = vmailUserName; mailLocation = dovecot_maildir; diff --git a/mail-server/networking.nix b/mail-server/networking.nix index 81c2d15..750f2e8 100644 --- a/mail-server/networking.nix +++ b/mail-server/networking.nix @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ domain, hostPrefix, enable_imap, enable_pop3 }: +{ domain, hostPrefix, enableImap, enablePop3 }: { #hostName = "${hostPrefix}.${domain}"; @@ -22,7 +22,7 @@ firewall = { enable = true; allowedTCPPorts = [ 25 587 ] - ++ (if enable_imap then [ 143 ] else []) - ++ (if enable_pop3 then [ 110 ] else []); + ++ (if enableImap then [ 143 ] else []) + ++ (if enablePop3 then [ 110 ] else []); }; } diff --git a/mail-server/rmilter.nix b/mail-server/rmilter.nix index ea62a9f..d003779 100644 --- a/mail-server/rmilter.nix +++ b/mail-server/rmilter.nix @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ domain, virusScanning, dkim_signing, dkim_dir, dkim_selector }: +{ domain, virusScanning, dkimSigning, dkimKeyDirectory, dkimSelector }: let clamav = if virusScanning @@ -25,14 +25,14 @@ let }; '' else ""; - dkim = if dkim_signing + dkim = if dkimSigning then '' dkim { domain { - key = "${dkim_dir}"; + key = "${dkimKeyDirectory}"; domain = "*"; - selector = "${dkim_selector}"; + selector = "${dkimSelector}"; }; sign_alg = sha256; auth_only = yes; diff --git a/mail-server/services.nix b/mail-server/services.nix index 7d2188c..c17b961 100644 --- a/mail-server/services.nix +++ b/mail-server/services.nix @@ -14,23 +14,24 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ lib, mailDirectory, vmailUserName, vmailGroupName, virtualAliases, domain, enable_imap, -enable_pop3, virusScanning, dkim_signing, dkim_selector, dkim_dir, -certificateScheme, certificateFile, keyFile, cert_dir }: +{ lib, mailDirectory, vmailUserName, vmailGroupName, virtualAliases, domain, +enableImap, enablePop3, virusScanning, dkimSigning, dkimSelector, +dkimKeyDirectory, certificateScheme, certificateFile, keyFile, +certificateDirectory }: let # cert :: PATH cert = if certificateScheme == 1 then certificateFile else if certificateScheme == 2 - then "${cert_dir}/cert-${domain}.pem" + then "${certificateDirectory}/cert-${domain}.pem" else ""; # key :: PATH key = if certificateScheme == 1 then keyFile else if certificateScheme == 2 - then "${cert_dir}/key-${domain}.pem" + then "${certificateDirectory}/key-${domain}.pem" else ""; in { @@ -40,7 +41,7 @@ in }; rmilter = import ./rmilter.nix { - inherit domain virusScanning dkim_signing dkim_selector dkim_dir; + inherit domain virusScanning dkimSigning dkimSelector dkimKeyDirectory; }; postfix = import ./postfix.nix { @@ -48,7 +49,7 @@ in }; dovecot2 = import ./dovecot.nix { - inherit vmailGroupName vmailUserName mailDirectory enable_imap - enable_pop3 cert key; + inherit vmailGroupName vmailUserName mailDirectory enableImap + enablePop3 cert key; }; } diff --git a/mail-server/systemd.nix b/mail-server/systemd.nix index fe3c688..24d4a7e 100644 --- a/mail-server/systemd.nix +++ b/mail-server/systemd.nix @@ -14,14 +14,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ pkgs, mailDirectory, vmailGroupName, certificateScheme, cert_dir, hostPrefix, -domain, dkim_selector, dkim_dir}: +{ pkgs, mailDirectory, vmailGroupName, certificateScheme, certificateDirectory, hostPrefix, +domain, dkimSelector, dkimKeyDirectory}: let create_certificate = if certificateScheme == 2 then '' # Create certificates if they do not exist yet - dir="${cert_dir}" + dir="${certificateDirectory}" fqdn="${hostPrefix}.${domain}" case $fqdn in /*) fqdn=$(cat "$fqdn");; esac key="''${dir}/key-${domain}.pem"; @@ -29,7 +29,7 @@ let if [ ! -f "''${key}" ] || [ ! -f "''${cert}" ] then - mkdir -p "${cert_dir}" + mkdir -p "${certificateDirectory}" (umask 077; "${pkgs.openssl}/bin/openssl" genrsa -out "''${key}" 2048) && "${pkgs.openssl}/bin/openssl" req -new -key "''${key}" -x509 -subj "/CN=''${fqdn}" \ -days 3650 -out "''${cert}" @@ -37,20 +37,20 @@ let '' else ""; - dkim_key = "${dkim_dir}/${dkim_selector}.private"; - dkim_txt = "${dkim_dir}/${dkim_selector}.txt"; + dkim_key = "${dkimKeyDirectory}/${dkimSelector}.private"; + dkim_txt = "${dkimKeyDirectory}/${dkimSelector}.txt"; create_dkim_cert = '' # Create dkim dir - mkdir -p "${dkim_dir}" - chown rmilter:rmilter "${dkim_dir}" + mkdir -p "${dkimKeyDirectory}" + chown rmilter:rmilter "${dkimKeyDirectory}" if [ ! -f "${dkim_key}" ] || [ ! -f "${dkim_txt}" ] then - ${pkgs.opendkim}/bin/opendkim-genkey -s "${dkim_selector}" \ + ${pkgs.opendkim}/bin/opendkim-genkey -s "${dkimSelector}" \ -d ${domain} \ - --directory="${dkim_dir}" + --directory="${dkimKeyDirectory}" chown rmilter:rmilter "${dkim_key}" fi '';