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
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
61
mail-server/services.nix
Normal file
61
mail-server/services.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
# 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/>
|
||||
|
||||
{ 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/";
|
||||
vmail_user = [{
|
||||
name = vmail_user_name;
|
||||
isNormalUser = false;
|
||||
uid = vmail_id_start;
|
||||
home = mail_dir;
|
||||
createHome = true;
|
||||
group = vmail_group_name;
|
||||
}];
|
||||
|
||||
# accountsToUser :: String -> UserRecord
|
||||
accountsToUser = x: {
|
||||
name = x + "@" + domain;
|
||||
isNormalUser = false;
|
||||
group = vmail_group_name;
|
||||
};
|
||||
|
||||
# mail_user :: [ UserRecord ]
|
||||
mail_user = map accountsToUser login_accounts;
|
||||
|
||||
# valiasToString :: { from = "..."; to = "..." } -> String
|
||||
valiasToString = x: x.from + "@" + domain + " " + x.to "@" + domain + "\n";
|
||||
|
||||
# valias_file :: [ String ]
|
||||
valiases_file = map valiasToString valiases;
|
||||
in
|
||||
{
|
||||
# rspamd
|
||||
rspamd = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
postfix = import ./postfix.nix {
|
||||
valiases_file = ""; vaccounts_file = ""; #< TODO: FIX
|
||||
};
|
||||
|
||||
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…
Add table
Add a link
Reference in a new issue