mirror of
https://gitlab.com/simple-nixos-mailserver/nixos-mailserver.git
synced 2024-11-11 19:39:16 +05:00
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;
|
||||
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 {
|
||||
|
@ -14,7 +14,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# 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 }:
|
||||
|
||||
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;
|
||||
|
@ -14,7 +14,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# 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}";
|
||||
@ -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 []);
|
||||
};
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# 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
|
||||
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;
|
||||
|
@ -14,23 +14,24 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
{ 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;
|
||||
};
|
||||
}
|
||||
|
@ -14,14 +14,14 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
{ 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
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user