1
0
Fork 0

Generate mail accounts from a user list.

This commit is contained in:
Kevin Baensch 2019-08-27 16:01:04 +02:00
parent 9f49f3fcf0
commit 51e986da9c
3 changed files with 17 additions and 9 deletions

View File

@ -11,6 +11,7 @@ with lib;
config.machine = rec {
hostName = "Ophanim";
administrators = [ { name = "derped"; id = 1337; } ];
mailAccounts = [ "derped" "mailman3" ];
domain = "ophanim.de";
allowUnfree = true;
conffiles = [

View File

@ -47,6 +47,12 @@ with lib;
The Machines domain name.
'';
};
mailAccounts = mkOption {
type = types.listOf types.string;
description = ''
List of mail account user names.
'';
};
vHosts = mkOption {
type = types.listOf types.attrs;
description = ''

View File

@ -3,18 +3,19 @@
with lib;
mkIf (elem "mailserver" config.machine.services) {
mailserver = rec {
mailserver = let
mkUser = username: {
name = "${username}@${config.machine.domain}";
value = {
hashedPassword = (fileContents "/secret/${username}.mail");
};
};
in rec {
enable = true;
fqdn = "mail.${config.machine.domain}";
domains = [ config.machine.domain ];
loginAccounts = {
"derped@${config.machine.domain}" = {
hashedPassword = (fileContents /secret/derped.mail);
};
"mailman3@${config.machine.domain}" = {
hashedPassword = (fileContents /secret/mailman3.mail);
};
};
loginAccounts = listToAttrs (map mkUser config.machine.mailAccounts);
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
# down nginx and opens port 80.
certificateScheme = 1;