camelCase
This commit is contained in:
parent
061054926d
commit
b5fccc7e39
43
default.nix
43
default.nix
|
@ -32,7 +32,7 @@ in
|
|||
description = "The domain that this mail server serves. So far only one domain is supported";
|
||||
};
|
||||
|
||||
host_prefix = mkOption {
|
||||
hostPrefix = mkOption {
|
||||
type = types.str;
|
||||
default = "mail";
|
||||
description = ''
|
||||
|
@ -41,7 +41,7 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
login_accounts = mkOption {
|
||||
loginAccounts = mkOption {
|
||||
type = types.loaOf (types.submodule ({ name, ... }: {
|
||||
options = {
|
||||
name = mkOption {
|
||||
|
@ -85,8 +85,8 @@ in
|
|||
default = {};
|
||||
};
|
||||
|
||||
valiases = mkOption {
|
||||
type = types.attrsOf (types.enum (builtins.attrNames cfg.login_accounts));
|
||||
virtualAliases = mkOption {
|
||||
type = types.attrsOf (types.enum (builtins.attrNames cfg.loginAccounts));
|
||||
example = {
|
||||
info = "user1";
|
||||
postmaster = "user1";
|
||||
|
@ -102,16 +102,16 @@ in
|
|||
default = {};
|
||||
};
|
||||
|
||||
vmail_id_start = mkOption {
|
||||
vmailUIDStart = mkOption {
|
||||
type = types.int;
|
||||
default = 5000;
|
||||
description = ''
|
||||
The unix UID where the login_accounts are created. 5000 means that the first
|
||||
The unix UID where the loginAccounts are created. 5000 means that the first
|
||||
user will get 5000, the second 5001, ...
|
||||
'';
|
||||
};
|
||||
|
||||
vmail_user_name = mkOption {
|
||||
vmailUserName = mkOption {
|
||||
type = types.str;
|
||||
default = "vmail";
|
||||
description = ''
|
||||
|
@ -120,7 +120,7 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
vmail_group_name = mkOption {
|
||||
vmailGroupName = mkOption {
|
||||
type = types.str;
|
||||
default = "vmail";
|
||||
description = ''
|
||||
|
@ -129,7 +129,7 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
mail_dir = mkOption {
|
||||
mailDirectory = mkOption {
|
||||
type = types.string;
|
||||
default = "/var/vmail";
|
||||
description = ''
|
||||
|
@ -137,7 +137,7 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
certificate_scheme = mkOption {
|
||||
certificateScheme = mkOption {
|
||||
type = types.enum [ 1 2 ];
|
||||
default = 2;
|
||||
description = ''
|
||||
|
@ -154,7 +154,7 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
cert_file = mkOption {
|
||||
certificateFile = mkOption {
|
||||
type = types.path;
|
||||
example = "/root/mail-server.crt";
|
||||
description = ''
|
||||
|
@ -163,7 +163,7 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
key_file = mkOption {
|
||||
keyFile = mkOption {
|
||||
type = types.path;
|
||||
example = "/root/mail-server.key";
|
||||
description = ''
|
||||
|
@ -212,7 +212,7 @@ in
|
|||
# imapSsl = mkOption {} #< TODO
|
||||
# pop3Ssl = mkOption {} #< TODO
|
||||
|
||||
virus_scanning = mkOption {
|
||||
virusScanning = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
|
@ -254,30 +254,31 @@ in
|
|||
config = mkIf cfg.enable {
|
||||
services = import ./mail-server/services.nix {
|
||||
inherit lib;
|
||||
inherit (cfg) mail_dir vmail_user_name vmail_group_name valiases domain
|
||||
inherit (cfg) mailDirectory vmailUserName vmailGroupName virtualAliases domain
|
||||
enable_imap enable_pop3 dkim_signing dkim_selector dkim_dir
|
||||
certificate_scheme cert_file key_file cert_dir virus_scanning;
|
||||
certificateScheme certificateFile keyFile cert_dir virusScanning;
|
||||
};
|
||||
|
||||
environment = import ./mail-server/environment.nix {
|
||||
inherit pkgs;
|
||||
inherit (cfg) certificate_scheme;
|
||||
inherit (cfg) certificateScheme;
|
||||
};
|
||||
|
||||
networking = import ./mail-server/networking.nix {
|
||||
inherit (cfg) domain host_prefix enable_imap enable_pop3;
|
||||
inherit (cfg) domain hostPrefix enable_imap enable_pop3;
|
||||
};
|
||||
|
||||
systemd = import ./mail-server/systemd.nix {
|
||||
inherit pkgs;
|
||||
inherit (cfg) mail_dir vmail_group_name certificate_scheme cert_dir host_prefix
|
||||
domain dkim_selector dkim_dir;
|
||||
inherit (cfg) mailDirectory vmailGroupName certificateScheme cert_dir
|
||||
hostPrefix domain dkim_selector dkim_dir;
|
||||
};
|
||||
|
||||
users = import ./mail-server/users.nix {
|
||||
inherit lib;
|
||||
inherit (cfg) vmail_id_start vmail_user_name vmail_group_name domain mail_dir
|
||||
login_accounts;
|
||||
inherit (cfg) vmailUIDStart vmailUserName vmailGroupName domain
|
||||
mailDirectory
|
||||
loginAccounts;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ let
|
|||
cfg = config.mailserver;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.virus_scanning {
|
||||
config = lib.mkIf cfg.virusScanning {
|
||||
services.clamav.daemon.enable = true;
|
||||
services.clamav.updater.enable = true;
|
||||
};
|
||||
|
|
|
@ -14,27 +14,27 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
{ vmail_group_name, vmail_user_name, mail_dir, enable_imap, enable_pop3, cert,
|
||||
{ vmailGroupName, vmailUserName, mailDirectory, enable_imap, enable_pop3, cert,
|
||||
key }:
|
||||
|
||||
let
|
||||
# maildir in format "/${domain}/${user}/"
|
||||
dovecot_maildir = "maildir:${mail_dir}/%d/%n/";
|
||||
dovecot_maildir = "maildir:${mailDirectory}/%d/%n/";
|
||||
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
enableImap = enable_imap;
|
||||
enablePop3 = enable_pop3;
|
||||
mailGroup = vmail_group_name;
|
||||
mailUser = vmail_user_name;
|
||||
mailGroup = vmailGroupName;
|
||||
mailUser = vmailUserName;
|
||||
mailLocation = dovecot_maildir;
|
||||
sslServerCert = cert;
|
||||
sslServerKey = key;
|
||||
enableLmtp = true;
|
||||
extraConfig = ''
|
||||
#Extra Config
|
||||
mail_access_groups = ${vmail_group_name}
|
||||
mail_access_groups = ${vmailGroupName}
|
||||
ssl = required
|
||||
|
||||
service lmtp {
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
# 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, certificate_scheme }:
|
||||
{ pkgs, certificateScheme }:
|
||||
|
||||
{
|
||||
systemPackages = with pkgs; [
|
||||
dovecot opendkim openssh postfix clamav rspamd rmilter
|
||||
] ++ (if certificate_scheme == 2 then [ openssl ] else []);
|
||||
] ++ (if certificateScheme == 2 then [ openssl ] else []);
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
# 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, host_prefix, enable_imap, enable_pop3 }:
|
||||
{ domain, hostPrefix, enable_imap, enable_pop3 }:
|
||||
|
||||
{
|
||||
#hostName = "${host_prefix}.${domain}";
|
||||
#hostName = "${hostPrefix}.${domain}";
|
||||
|
||||
firewall = {
|
||||
enable = true;
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
# 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, mail_dir, domain, valiases, cert, key }:
|
||||
{ lib, mailDirectory, domain, virtualAliases, cert, key }:
|
||||
|
||||
let
|
||||
# valiases_postfix :: [ String ]
|
||||
valiases_postfix = map
|
||||
(from:
|
||||
let to = valiases.${from};
|
||||
let to = virtualAliases.${from};
|
||||
in "${from}@${domain} ${to}@${domain}")
|
||||
(builtins.attrNames valiases);
|
||||
(builtins.attrNames virtualAliases);
|
||||
|
||||
# valiases_file :: Path
|
||||
valiases_file = builtins.toFile "valias" (lib.concatStringsSep "\n" valiases_postfix);
|
||||
|
@ -60,7 +60,7 @@ in
|
|||
# virtual mail system
|
||||
virtual_uid_maps = static:5000
|
||||
virtual_gid_maps = static:5000
|
||||
virtual_mailbox_base = ${mail_dir}
|
||||
virtual_mailbox_base = ${mailDirectory}
|
||||
virtual_mailbox_domains = ${vhosts_file}
|
||||
virtual_alias_maps = hash:/var/lib/postfix/conf/valias
|
||||
virtual_transport = lmtp:unix:private/dovecot-lmtp
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
# 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, virus_scanning, dkim_signing, dkim_dir, dkim_selector }:
|
||||
{ domain, virusScanning, dkim_signing, dkim_dir, dkim_selector }:
|
||||
|
||||
let
|
||||
clamav = if virus_scanning
|
||||
clamav = if virusScanning
|
||||
then
|
||||
''
|
||||
clamav {
|
||||
|
|
|
@ -14,22 +14,22 @@
|
|||
# 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, mail_dir, vmail_user_name, vmail_group_name, valiases, domain, enable_imap,
|
||||
enable_pop3, virus_scanning, dkim_signing, dkim_selector, dkim_dir,
|
||||
certificate_scheme, cert_file, key_file, cert_dir }:
|
||||
{ lib, mailDirectory, vmailUserName, vmailGroupName, virtualAliases, domain, enable_imap,
|
||||
enable_pop3, virusScanning, dkim_signing, dkim_selector, dkim_dir,
|
||||
certificateScheme, certificateFile, keyFile, cert_dir }:
|
||||
|
||||
let
|
||||
# cert :: PATH
|
||||
cert = if certificate_scheme == 1
|
||||
then cert_file
|
||||
else if certificate_scheme == 2
|
||||
cert = if certificateScheme == 1
|
||||
then certificateFile
|
||||
else if certificateScheme == 2
|
||||
then "${cert_dir}/cert-${domain}.pem"
|
||||
else "";
|
||||
|
||||
# key :: PATH
|
||||
key = if certificate_scheme == 1
|
||||
then key_file
|
||||
else if certificate_scheme == 2
|
||||
key = if certificateScheme == 1
|
||||
then keyFile
|
||||
else if certificateScheme == 2
|
||||
then "${cert_dir}/key-${domain}.pem"
|
||||
else "";
|
||||
in
|
||||
|
@ -40,15 +40,15 @@ in
|
|||
};
|
||||
|
||||
rmilter = import ./rmilter.nix {
|
||||
inherit domain virus_scanning dkim_signing dkim_selector dkim_dir;
|
||||
inherit domain virusScanning dkim_signing dkim_selector dkim_dir;
|
||||
};
|
||||
|
||||
postfix = import ./postfix.nix {
|
||||
inherit lib mail_dir domain valiases cert key;
|
||||
inherit lib mailDirectory domain virtualAliases cert key;
|
||||
};
|
||||
|
||||
dovecot2 = import ./dovecot.nix {
|
||||
inherit vmail_group_name vmail_user_name mail_dir enable_imap
|
||||
inherit vmailGroupName vmailUserName mailDirectory enable_imap
|
||||
enable_pop3 cert key;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
# 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, mail_dir, vmail_group_name, certificate_scheme, cert_dir, host_prefix,
|
||||
{ pkgs, mailDirectory, vmailGroupName, certificateScheme, cert_dir, hostPrefix,
|
||||
domain, dkim_selector, dkim_dir}:
|
||||
|
||||
let
|
||||
create_certificate = if certificate_scheme == 2 then
|
||||
create_certificate = if certificateScheme == 2 then
|
||||
''
|
||||
# Create certificates if they do not exist yet
|
||||
dir="${cert_dir}"
|
||||
fqdn="${host_prefix}.${domain}"
|
||||
fqdn="${hostPrefix}.${domain}"
|
||||
case $fqdn in /*) fqdn=$(cat "$fqdn");; esac
|
||||
key="''${dir}/key-${domain}.pem";
|
||||
cert="''${dir}/cert-${domain}.pem";
|
||||
|
@ -68,9 +68,9 @@ in
|
|||
preStart =
|
||||
''
|
||||
# Create mail directory and set permissions
|
||||
mkdir -p "${mail_dir}"
|
||||
chgrp "${vmail_group_name}" "${mail_dir}"
|
||||
chmod 02770 "${mail_dir}"
|
||||
mkdir -p "${mailDirectory}"
|
||||
chgrp "${vmailGroupName}" "${mailDirectory}"
|
||||
chmod 02770 "${mailDirectory}"
|
||||
|
||||
${create_certificate}
|
||||
'';
|
||||
|
|
|
@ -14,35 +14,35 @@
|
|||
# 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, vmail_id_start, vmail_user_name, vmail_group_name, domain, mail_dir,
|
||||
login_accounts }:
|
||||
{ lib, vmailUIDStart, vmailUserName, vmailGroupName, domain, mailDirectory,
|
||||
loginAccounts }:
|
||||
|
||||
let
|
||||
vmail_user = [{
|
||||
name = vmail_user_name;
|
||||
name = vmailUserName;
|
||||
isNormalUser = false;
|
||||
uid = vmail_id_start;
|
||||
home = mail_dir;
|
||||
uid = vmailUIDStart;
|
||||
home = mailDirectory;
|
||||
createHome = true;
|
||||
group = vmail_group_name;
|
||||
group = vmailGroupName;
|
||||
}];
|
||||
|
||||
# accountsToUser :: String -> UserRecord
|
||||
accountsToUser = account: {
|
||||
name = account.name + "@" + domain;
|
||||
isNormalUser = false;
|
||||
group = vmail_group_name;
|
||||
group = vmailGroupName;
|
||||
inherit (account) hashedPassword;
|
||||
};
|
||||
|
||||
# mail_user :: [ UserRecord ]
|
||||
mail_user = map accountsToUser (lib.attrValues login_accounts);
|
||||
mail_user = map accountsToUser (lib.attrValues loginAccounts);
|
||||
|
||||
in
|
||||
{
|
||||
# set the vmail gid to a specific value
|
||||
groups = {
|
||||
vmail = { gid = vmail_id_start; };
|
||||
vmail = { gid = vmailUIDStart; };
|
||||
};
|
||||
|
||||
# define all users
|
||||
|
|
Loading…
Reference in New Issue