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