From b5fccc7e39be5a69ea0d4b64e1763ab7f2d019fd Mon Sep 17 00:00:00 2001 From: Robin Raymond Date: Sat, 2 Sep 2017 13:23:37 +0200 Subject: [PATCH] camelCase --- default.nix | 43 +++++++++++++++++++------------------ mail-server/clamav.nix | 2 +- mail-server/dovecot.nix | 10 ++++----- mail-server/environment.nix | 4 ++-- mail-server/networking.nix | 4 ++-- mail-server/postfix.nix | 8 +++---- mail-server/rmilter.nix | 4 ++-- mail-server/services.nix | 24 ++++++++++----------- mail-server/systemd.nix | 12 +++++------ mail-server/users.nix | 18 ++++++++-------- 10 files changed, 65 insertions(+), 64 deletions(-) diff --git a/default.nix b/default.nix index 2edb0eb..a2158a6 100644 --- a/default.nix +++ b/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; }; }; } diff --git a/mail-server/clamav.nix b/mail-server/clamav.nix index 9bf0737..5542a95 100644 --- a/mail-server/clamav.nix +++ b/mail-server/clamav.nix @@ -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; }; diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index b294ac1..d94539e 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -14,27 +14,27 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ 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 { diff --git a/mail-server/environment.nix b/mail-server/environment.nix index 3b61430..4ffdd2a 100644 --- a/mail-server/environment.nix +++ b/mail-server/environment.nix @@ -14,10 +14,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ 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 []); } diff --git a/mail-server/networking.nix b/mail-server/networking.nix index 990c13a..81c2d15 100644 --- a/mail-server/networking.nix +++ b/mail-server/networking.nix @@ -14,10 +14,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ domain, host_prefix, enable_imap, enable_pop3 }: +{ domain, hostPrefix, enable_imap, enable_pop3 }: { - #hostName = "${host_prefix}.${domain}"; + #hostName = "${hostPrefix}.${domain}"; firewall = { enable = true; diff --git a/mail-server/postfix.nix b/mail-server/postfix.nix index fb4dbc1..cc2817e 100644 --- a/mail-server/postfix.nix +++ b/mail-server/postfix.nix @@ -14,15 +14,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ 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 diff --git a/mail-server/rmilter.nix b/mail-server/rmilter.nix index 911eaf8..ea62a9f 100644 --- a/mail-server/rmilter.nix +++ b/mail-server/rmilter.nix @@ -14,10 +14,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ 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 { diff --git a/mail-server/services.nix b/mail-server/services.nix index 880536c..7d2188c 100644 --- a/mail-server/services.nix +++ b/mail-server/services.nix @@ -14,22 +14,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ 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; }; } diff --git a/mail-server/systemd.nix b/mail-server/systemd.nix index 817a760..fe3c688 100644 --- a/mail-server/systemd.nix +++ b/mail-server/systemd.nix @@ -14,15 +14,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ 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} ''; diff --git a/mail-server/users.nix b/mail-server/users.nix index de1c1ab..cae2b83 100644 --- a/mail-server/users.nix +++ b/mail-server/users.nix @@ -14,35 +14,35 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ 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