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 {
|
config.machine = rec {
|
||||||
hostName = "Ophanim";
|
hostName = "Ophanim";
|
||||||
administrators = [ { name = "derped"; id = 1337; } ];
|
administrators = [ { name = "derped"; id = 1337; } ];
|
||||||
|
mailAccounts = [ "derped" "mailman3" ];
|
||||||
domain = "ophanim.de";
|
domain = "ophanim.de";
|
||||||
allowUnfree = true;
|
allowUnfree = true;
|
||||||
conffiles = [
|
conffiles = [
|
||||||
|
|
|
@ -47,6 +47,12 @@ with lib;
|
||||||
The Machines domain name.
|
The Machines domain name.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
mailAccounts = mkOption {
|
||||||
|
type = types.listOf types.string;
|
||||||
|
description = ''
|
||||||
|
List of mail account user names.
|
||||||
|
'';
|
||||||
|
};
|
||||||
vHosts = mkOption {
|
vHosts = mkOption {
|
||||||
type = types.listOf types.attrs;
|
type = types.listOf types.attrs;
|
||||||
description = ''
|
description = ''
|
||||||
|
|
|
@ -3,18 +3,19 @@
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
mkIf (elem "mailserver" config.machine.services) {
|
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;
|
enable = true;
|
||||||
fqdn = "mail.${config.machine.domain}";
|
fqdn = "mail.${config.machine.domain}";
|
||||||
domains = [ config.machine.domain ];
|
domains = [ config.machine.domain ];
|
||||||
loginAccounts = {
|
loginAccounts = listToAttrs (map mkUser config.machine.mailAccounts);
|
||||||
"derped@${config.machine.domain}" = {
|
|
||||||
hashedPassword = (fileContents /secret/derped.mail);
|
|
||||||
};
|
|
||||||
"mailman3@${config.machine.domain}" = {
|
|
||||||
hashedPassword = (fileContents /secret/mailman3.mail);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
|
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
|
||||||
# down nginx and opens port 80.
|
# down nginx and opens port 80.
|
||||||
certificateScheme = 1;
|
certificateScheme = 1;
|
||||||
|
|
Loading…
Reference in a new issue