restructuring; now works with 17.03/17.09-pre
I had to remove some of the features, they need to be slowely added in again.
This commit is contained in:
parent
54e56926d6
commit
60574841c6
7 changed files with 125 additions and 56 deletions
|
@ -1,5 +1,5 @@
|
|||
# nixos-mailserver: a simple mail server
|
||||
# Copyright (C) 2016 Robin Raymond
|
||||
# Copyright (C) 2016-2017 Robin Raymond
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -45,5 +45,24 @@ let
|
|||
virus_scanning = false;
|
||||
in
|
||||
{
|
||||
imports = [ ./mail-server.nix ];
|
||||
services = import ./mail-server/services.nix {
|
||||
inherit mail_dir vmail_user_name vmail_id_start vmail_group_name
|
||||
login_accounts valiases domain enable_imap enable_pop3;
|
||||
};
|
||||
|
||||
environment = import ./mail-server/environment.nix {
|
||||
inherit pkgs;
|
||||
};
|
||||
|
||||
networking = import ./mail-server/networking.nix {
|
||||
inherit domain host_prefix;
|
||||
};
|
||||
|
||||
# TODO: Move to /mail-server/systemd.nix
|
||||
# TODO: Respect setting of maildir
|
||||
# Set the correct permissions for dovecot vmail folder. See
|
||||
# <http://wiki2.dovecot.org/SharedMailboxes/Permissions>. We choose
|
||||
# to use the systemd service to set the folder permissions whenever
|
||||
# dovecot gets started.
|
||||
systemd.services.dovecot2.preStart = "chmod 02770 /var/vmail";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# nixos-mailserver: a simple mail server
|
||||
# Copyright (C) 2016 Robin Raymond
|
||||
# Copyright (C) 2016-2017 Robin Raymond
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -14,21 +14,13 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
{ config, pkgs, vmail_group_name, vmail_user_name, dovecot_maildir, enable_imap,
|
||||
enable_pop3, ... }:
|
||||
{ vmail_group_name, vmail_user_name, dovecot_maildir, enable_imap, enable_pop3,
|
||||
... }:
|
||||
{
|
||||
# Set the correct permissions for dovecot vmail folder. See
|
||||
# <http://wiki2.dovecot.org/SharedMailboxes/Permissions>. We choose
|
||||
# to use the systemd service to set the folder permissions whenever
|
||||
# dovecot gets started.
|
||||
systemd.services.dovecot2.preStart = "chmod 02770 /var/vmail";
|
||||
|
||||
services.dovecot2 = {
|
||||
enable = true;
|
||||
enableImap = enable_imap; # IMAP
|
||||
enablePop3 = enable_pop3; # POP3
|
||||
mailGroup = vmail_group_name;
|
||||
mailUser = vmail_user_name;
|
||||
mailLocation = dovecot_maildir; # maildir in format "/${domain}/${user}/"
|
||||
};
|
||||
enable = true;
|
||||
enableImap = enable_imap;
|
||||
enablePop3 = enable_pop3;
|
||||
mailGroup = vmail_group_name;
|
||||
mailUser = vmail_user_name;
|
||||
mailLocation = dovecot_maildir; # maildir in format "/${domain}/${user}/"
|
||||
}
|
||||
|
|
23
mail-server/environment.nix
Normal file
23
mail-server/environment.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
# nixos-mailserver: a simple mail server
|
||||
# Copyright (C) 2016-2017 Robin Raymond
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# 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, ... }:
|
||||
|
||||
{
|
||||
systemPackages = with pkgs; [
|
||||
dovecot opendkim openssh postfix clamav rspamd rmilter
|
||||
];
|
||||
}
|
26
mail-server/networking.nix
Normal file
26
mail-server/networking.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
# nixos-mailserver: a simple mail server
|
||||
# Copyright (C) 2016-2017 Robin Raymond
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# 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, ... }:
|
||||
|
||||
{
|
||||
hostName = host_prefix + "." + domain;
|
||||
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [ 25 143 587 ]; # < TODO: make this flexible
|
||||
};
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
# nixos-mailserver: a simple mail server
|
||||
# Copyright (C) 2016 Robin Raymond
|
||||
# Copyright (C) 2016-2017 Robin Raymond
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -14,12 +14,11 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
{ config, pkgs, valias_file, vaccounts_file, ... }:
|
||||
{ valiases_file, vaccounts_file, ... }:
|
||||
|
||||
{
|
||||
services.postfix = {
|
||||
enable = true;
|
||||
networksStyle = "host";
|
||||
mapFiles."valias" = valias_file;
|
||||
mapFiles."vaccounts" = vaccounts_file;
|
||||
};
|
||||
enable = true;
|
||||
networksStyle = "host";
|
||||
# mapFiles."valias" = valiases_file;
|
||||
# mapFiles."vaccounts" = vaccounts_file;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# nixos-mailserver: a simple mail server
|
||||
# Copyright (C) 2016 Robin Raymond
|
||||
# Copyright (C) 2016-2017 Robin Raymond
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -14,8 +14,8 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
{ config, pkgs, mail_dir, vmail_user_name, vmail_id_start, vmail_group_name,
|
||||
domain, login_accounts, valiases, host_prefix, ... }:
|
||||
{ mail_dir, vmail_user_name, vmail_id_start, vmail_group_name, login_accounts,
|
||||
valiases, domain, enable_imap, enable_pop3 }:
|
||||
|
||||
let
|
||||
dovecot_maildir = "maildir:" + mail_dir + "/%d/%n/";
|
||||
|
@ -41,38 +41,21 @@ let
|
|||
# valiasToString :: { from = "..."; to = "..." } -> String
|
||||
valiasToString = x: x.from + "@" + domain + " " + x.to "@" + domain + "\n";
|
||||
|
||||
# valiasFile :: [ String ]
|
||||
valiasFile = map valiasToString valiases;
|
||||
# valias_file :: [ String ]
|
||||
valiases_file = map valiasToString valiases;
|
||||
in
|
||||
{
|
||||
networking.hostName = host_prefix + "." + domain;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
dovecot opendkim openssh postfix clamav rspamd rmilter
|
||||
];
|
||||
|
||||
# set the vmail gid to a specific value
|
||||
users.groups = {
|
||||
vmail = { gid = vmail_id_start; };
|
||||
};
|
||||
|
||||
# define all users
|
||||
users.extraUsers = vmail_user ++ mail_user;
|
||||
|
||||
|
||||
# rspamd
|
||||
services.rspamd = {
|
||||
rspamd = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
# firewall
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [ 25 143 587 ]; # < TODO: make this flexible
|
||||
postfix = import ./postfix.nix {
|
||||
valiases_file = ""; vaccounts_file = ""; #< TODO: FIX
|
||||
};
|
||||
|
||||
imports = [
|
||||
./mail-server/dovecot.nix # dovecot
|
||||
./mail-server/postfix.nix # postfix
|
||||
];
|
||||
dovecot2 = import ./dovecot.nix {
|
||||
inherit vmail_group_name vmail_user_name dovecot_maildir enable_imap
|
||||
enable_pop3;
|
||||
};
|
||||
}
|
27
mail-server/users.nix
Normal file
27
mail-server/users.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
# nixos-mailserver: a simple mail server
|
||||
# Copyright (C) 2016-2017 Robin Raymond
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# 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_id_start, vmail_user, mail_user }:
|
||||
|
||||
{
|
||||
# set the vmail gid to a specific value
|
||||
users.groups = {
|
||||
vmail = { gid = vmail_id_start; };
|
||||
};
|
||||
|
||||
# define all users
|
||||
users.extraUsers = vmail_user ++ mail_user;
|
||||
}
|
Loading…
Reference in a new issue