clean configuration; simple-nixos-mailserver is an ordinary SP module
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
[
|
||||
[ "mailserver" ],
|
||||
[ "selfprivacy", "domain" ],
|
||||
[ "selfprivacy", "email" ],
|
||||
[ "selfprivacy", "hashedMasterPassword" ],
|
||||
[ "selfprivacy", "useBinds" ],
|
||||
[ "selfprivacy", "username" ],
|
||||
|
@@ -2,21 +2,23 @@ mailserverDate: { config, lib, ... }:
|
||||
let
|
||||
sp = config.selfprivacy;
|
||||
in
|
||||
lib.mkIf sp.modules.simple-nixos-mailserver.enable
|
||||
{
|
||||
fileSystems =
|
||||
lib.mkIf (sp.modules.simple-nixos-mailserver.enable && sp.useBinds)
|
||||
{
|
||||
"/var/vmail" = {
|
||||
device = "/volumes/${sp.email.location}/vmail";
|
||||
options = [ "bind" ];
|
||||
};
|
||||
"/var/sieve" = {
|
||||
device = "/volumes/${sp.email.location}/sieve";
|
||||
options = [ "bind" ];
|
||||
};
|
||||
fileSystems = lib.mkIf sp.useBinds
|
||||
{
|
||||
"/var/vmail" = {
|
||||
device =
|
||||
"/volumes/${sp.modules.simple-nixos-mailserver.location}/vmail";
|
||||
options = [ "bind" ];
|
||||
};
|
||||
"/var/sieve" = {
|
||||
device =
|
||||
"/volumes/${sp.modules.simple-nixos-mailserver.location}/sieve";
|
||||
options = [ "bind" ];
|
||||
};
|
||||
};
|
||||
|
||||
users.users = lib.mkIf sp.modules.simple-nixos-mailserver.enable {
|
||||
users.users = {
|
||||
virtualMail = {
|
||||
isNormalUser = false;
|
||||
};
|
||||
@@ -24,16 +26,30 @@ in
|
||||
|
||||
users.groups.acmereceivers.members = [ "dovecot2" "postfix" "virtualMail" ];
|
||||
|
||||
selfprivacy.modules.simple-nixos-mailserver =
|
||||
lib.mkIf sp.modules.simple-nixos-mailserver.enable {
|
||||
fqdn = sp.domain;
|
||||
domains = [ sp.domain ];
|
||||
mailserver = {
|
||||
enable = true;
|
||||
fqdn = sp.domain;
|
||||
domains = [ sp.domain ];
|
||||
|
||||
# A list of all login accounts. To create the password hashes, use
|
||||
# mkpasswd -m sha-512 "super secret password"
|
||||
loginAccounts = {
|
||||
"${sp.username}@${sp.domain}" = {
|
||||
hashedPassword = sp.hashedMasterPassword;
|
||||
# A list of all login accounts. To create the password hashes, use
|
||||
# mkpasswd -m sha-512 "super secret password"
|
||||
loginAccounts = {
|
||||
"${sp.username}@${sp.domain}" = {
|
||||
hashedPassword = sp.hashedMasterPassword;
|
||||
sieveScript = ''
|
||||
require ["fileinto", "mailbox"];
|
||||
if header :contains "Chat-Version" "1.0"
|
||||
{
|
||||
fileinto :create "DeltaChat";
|
||||
stop;
|
||||
}
|
||||
'';
|
||||
};
|
||||
} // builtins.listToAttrs (builtins.map
|
||||
(user: {
|
||||
name = "${user.username}@${sp.domain}";
|
||||
value = {
|
||||
hashedPassword = user.hashedPassword;
|
||||
sieveScript = ''
|
||||
require ["fileinto", "mailbox"];
|
||||
if header :contains "Chat-Version" "1.0"
|
||||
@@ -43,45 +59,31 @@ in
|
||||
}
|
||||
'';
|
||||
};
|
||||
} // builtins.listToAttrs (builtins.map
|
||||
(user: {
|
||||
name = "${user.username}@${sp.domain}";
|
||||
value = {
|
||||
hashedPassword = user.hashedPassword;
|
||||
sieveScript = ''
|
||||
require ["fileinto", "mailbox"];
|
||||
if header :contains "Chat-Version" "1.0"
|
||||
{
|
||||
fileinto :create "DeltaChat";
|
||||
stop;
|
||||
}
|
||||
'';
|
||||
};
|
||||
})
|
||||
sp.users);
|
||||
})
|
||||
sp.users);
|
||||
|
||||
extraVirtualAliases = {
|
||||
"admin@${sp.domain}" = "${sp.username}@${sp.domain}";
|
||||
};
|
||||
|
||||
certificateScheme =
|
||||
if builtins.compareVersions mailserverDate "20230525011002"
|
||||
>= 0
|
||||
then "manual"
|
||||
else 1;
|
||||
certificateFile = "/var/lib/acme/${sp.domain}/fullchain.pem";
|
||||
keyFile = "/var/lib/acme/${sp.domain}/key.pem";
|
||||
|
||||
# Enable IMAP and POP3
|
||||
enableImap = true;
|
||||
enableImapSsl = true;
|
||||
enablePop3 = false;
|
||||
enablePop3Ssl = false;
|
||||
dkimSelector = "selector";
|
||||
|
||||
# Enable the ManageSieve protocol
|
||||
enableManageSieve = true;
|
||||
|
||||
virusScanning = false;
|
||||
extraVirtualAliases = {
|
||||
"admin@${sp.domain}" = "${sp.username}@${sp.domain}";
|
||||
};
|
||||
|
||||
certificateScheme =
|
||||
if builtins.compareVersions mailserverDate "20230525011002"
|
||||
>= 0
|
||||
then "manual"
|
||||
else 1;
|
||||
certificateFile = "/var/lib/acme/${sp.domain}/fullchain.pem";
|
||||
keyFile = "/var/lib/acme/${sp.domain}/key.pem";
|
||||
|
||||
# Enable IMAP and POP3
|
||||
enableImap = true;
|
||||
enableImapSsl = true;
|
||||
enablePop3 = false;
|
||||
enablePop3Ssl = false;
|
||||
dkimSelector = "selector";
|
||||
|
||||
# Enable the ManageSieve protocol
|
||||
enableManageSieve = true;
|
||||
|
||||
virusScanning = false;
|
||||
};
|
||||
}
|
||||
|
@@ -5,23 +5,13 @@
|
||||
gitlab:simple-nixos-mailserver/nixos-mailserver;
|
||||
|
||||
outputs = { self, mailserver }: {
|
||||
nixosModules.default = args@{ config, ... }:
|
||||
let
|
||||
module = mailserver.nixosModules.default args;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
module
|
||||
{
|
||||
# tricks to rename (alias) the original module
|
||||
config.mailserver =
|
||||
config.selfprivacy.modules.simple-nixos-mailserver;
|
||||
options.selfprivacy.modules.simple-nixos-mailserver =
|
||||
module.options.mailserver;
|
||||
}
|
||||
(import ./config.nix mailserver.lastModifiedDate)
|
||||
];
|
||||
};
|
||||
nixosModules.default = _: {
|
||||
imports = [
|
||||
mailserver.nixosModules.default
|
||||
./options.nix
|
||||
(import ./config.nix mailserver.lastModifiedDate)
|
||||
];
|
||||
};
|
||||
configPathsNeeded =
|
||||
builtins.fromJSON (builtins.readFile ./config-paths-needed.json);
|
||||
|
||||
|
13
sp-modules/simple-nixos-mailserver/options.nix
Normal file
13
sp-modules/simple-nixos-mailserver/options.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
options.selfprivacy.modules.simple-nixos-mailserver = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
type = with lib.types; nullOr bool;
|
||||
};
|
||||
location = lib.mkOption {
|
||||
default = "sda1";
|
||||
type = with lib.types; nullOr str;
|
||||
};
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user