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
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -45,5 +45,24 @@ let
|
||||||
virus_scanning = false;
|
virus_scanning = false;
|
||||||
in
|
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
|
# 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
|
# 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
|
# 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
|
# 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/>
|
||||||
|
|
||||||
{ config, pkgs, vmail_group_name, vmail_user_name, dovecot_maildir, enable_imap,
|
{ vmail_group_name, vmail_user_name, dovecot_maildir, enable_imap, enable_pop3,
|
||||||
enable_pop3, ... }:
|
... }:
|
||||||
{
|
{
|
||||||
# Set the correct permissions for dovecot vmail folder. See
|
enable = true;
|
||||||
# <http://wiki2.dovecot.org/SharedMailboxes/Permissions>. We choose
|
enableImap = enable_imap;
|
||||||
# to use the systemd service to set the folder permissions whenever
|
enablePop3 = enable_pop3;
|
||||||
# dovecot gets started.
|
mailGroup = vmail_group_name;
|
||||||
systemd.services.dovecot2.preStart = "chmod 02770 /var/vmail";
|
mailUser = vmail_user_name;
|
||||||
|
mailLocation = dovecot_maildir; # maildir in format "/${domain}/${user}/"
|
||||||
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}/"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
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
|
# 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
|
# 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
|
# 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
|
# 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/>
|
||||||
|
|
||||||
{ config, pkgs, valias_file, vaccounts_file, ... }:
|
{ valiases_file, vaccounts_file, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
services.postfix = {
|
enable = true;
|
||||||
enable = true;
|
networksStyle = "host";
|
||||||
networksStyle = "host";
|
# mapFiles."valias" = valiases_file;
|
||||||
mapFiles."valias" = valias_file;
|
# mapFiles."vaccounts" = vaccounts_file;
|
||||||
mapFiles."vaccounts" = vaccounts_file;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# nixos-mailserver: a simple mail server
|
# 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
|
# 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
|
# 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
|
# 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/>
|
||||||
|
|
||||||
{ config, pkgs, mail_dir, vmail_user_name, vmail_id_start, vmail_group_name,
|
{ mail_dir, vmail_user_name, vmail_id_start, vmail_group_name, login_accounts,
|
||||||
domain, login_accounts, valiases, host_prefix, ... }:
|
valiases, domain, enable_imap, enable_pop3 }:
|
||||||
|
|
||||||
let
|
let
|
||||||
dovecot_maildir = "maildir:" + mail_dir + "/%d/%n/";
|
dovecot_maildir = "maildir:" + mail_dir + "/%d/%n/";
|
||||||
|
@ -41,38 +41,21 @@ let
|
||||||
# valiasToString :: { from = "..."; to = "..." } -> String
|
# valiasToString :: { from = "..."; to = "..." } -> String
|
||||||
valiasToString = x: x.from + "@" + domain + " " + x.to "@" + domain + "\n";
|
valiasToString = x: x.from + "@" + domain + " " + x.to "@" + domain + "\n";
|
||||||
|
|
||||||
# valiasFile :: [ String ]
|
# valias_file :: [ String ]
|
||||||
valiasFile = map valiasToString valiases;
|
valiases_file = map valiasToString valiases;
|
||||||
in
|
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
|
# rspamd
|
||||||
services.rspamd = {
|
rspamd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# firewall
|
postfix = import ./postfix.nix {
|
||||||
networking.firewall = {
|
valiases_file = ""; vaccounts_file = ""; #< TODO: FIX
|
||||||
enable = true;
|
|
||||||
allowedTCPPorts = [ 25 143 587 ]; # < TODO: make this flexible
|
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
dovecot2 = import ./dovecot.nix {
|
||||||
./mail-server/dovecot.nix # dovecot
|
inherit vmail_group_name vmail_user_name dovecot_maildir enable_imap
|
||||||
./mail-server/postfix.nix # postfix
|
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