Generate mail accounts from a user list.
This commit is contained in:
parent
9f49f3fcf0
commit
51e986da9c
3 changed files with 17 additions and 9 deletions
|
@ -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 = [
|
||||
|
|
|
@ -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 = ''
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue