From 9ac491f87df0ba838b3c9ec2e9f1c4999f2135a1 Mon Sep 17 00:00:00 2001 From: Robin Raymond Date: Sat, 2 Sep 2017 14:58:33 +0200 Subject: [PATCH] networking to module --- default.nix | 6 +----- mail-server/networking.nix | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/default.nix b/default.nix index 1d44211..242888e 100644 --- a/default.nix +++ b/default.nix @@ -251,6 +251,7 @@ in ./mail-server/clamav.nix ./mail-server/users.nix ./mail-server/environment.nix + ./mail-server/networking.nix ]; config = mkIf cfg.enable { @@ -261,16 +262,11 @@ in certificateScheme certificateFile keyFile certificateDirectory virusScanning; }; - networking = import ./mail-server/networking.nix { - inherit (cfg) domain hostPrefix enableImap enablePop3; - }; - systemd = import ./mail-server/systemd.nix { inherit pkgs; inherit (cfg) mailDirectory vmailGroupName certificateScheme certificateDirectory hostPrefix domain dkimSelector dkimKeyDirectory; }; - }; } diff --git a/mail-server/networking.nix b/mail-server/networking.nix index 750f2e8..e355252 100644 --- a/mail-server/networking.nix +++ b/mail-server/networking.nix @@ -14,15 +14,21 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ domain, hostPrefix, enableImap, enablePop3 }: +{ config, pkgs, lib, ... }: +let + cfg = config.mailserver; +in { - #hostName = "${hostPrefix}.${domain}"; + config = with cfg; lib.mkIf enable { - firewall = { - enable = true; - allowedTCPPorts = [ 25 587 ] - ++ (if enableImap then [ 143 ] else []) - ++ (if enablePop3 then [ 110 ] else []); + networking.hostName = "${hostPrefix}.${domain}"; + + networking.firewall = { + enable = true; + allowedTCPPorts = [ 25 587 ] + ++ (if enableImap then [ 143 ] else []) + ++ (if enablePop3 then [ 110 ] else []); + }; }; }