networking to module

This commit is contained in:
Robin Raymond 2017-09-02 14:58:33 +02:00
parent 201c532a67
commit 9ac491f87d
2 changed files with 14 additions and 12 deletions

View file

@ -251,6 +251,7 @@ in
./mail-server/clamav.nix ./mail-server/clamav.nix
./mail-server/users.nix ./mail-server/users.nix
./mail-server/environment.nix ./mail-server/environment.nix
./mail-server/networking.nix
]; ];
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -261,16 +262,11 @@ in
certificateScheme certificateFile keyFile certificateDirectory virusScanning; certificateScheme certificateFile keyFile certificateDirectory virusScanning;
}; };
networking = import ./mail-server/networking.nix {
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 inherit (cfg) mailDirectory vmailGroupName certificateScheme
certificateDirectory certificateDirectory
hostPrefix domain dkimSelector dkimKeyDirectory; hostPrefix domain dkimSelector dkimKeyDirectory;
}; };
}; };
} }

View file

@ -14,15 +14,21 @@
# 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, enableImap, enablePop3 }: { config, pkgs, lib, ... }:
let
cfg = config.mailserver;
in
{ {
#hostName = "${hostPrefix}.${domain}"; config = with cfg; lib.mkIf enable {
firewall = { networking.hostName = "${hostPrefix}.${domain}";
networking.firewall = {
enable = true; enable = true;
allowedTCPPorts = [ 25 587 ] allowedTCPPorts = [ 25 587 ]
++ (if enableImap then [ 143 ] else []) ++ (if enableImap then [ 143 ] else [])
++ (if enablePop3 then [ 110 ] else []); ++ (if enablePop3 then [ 110 ] else []);
}; };
};
} }