68 lines
1.7 KiB
Nix
68 lines
1.7 KiB
Nix
{ lib, config, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.mailserver;
|
|
in
|
|
{
|
|
options.services.mailserver = {
|
|
enable = mkEnableOption "Mail Server";
|
|
domaine = mkOption {
|
|
type = types.string;
|
|
example = "example.com";
|
|
description = "Nom de domaine du serveur de mails";
|
|
};
|
|
};
|
|
|
|
imports = [
|
|
(builtins.fetchTarball {
|
|
url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/8b7dde4b54da821ca3dc2058178d6ffbd2e25bc5/nixos-mailserver-8b7dde4b54da821ca3dc2058178d6ffbd2e25bc5.tar.gz";
|
|
sha256 = "0pf25ns3yq9vdbpb30cplx4zkj7srrklamd6kw7ifaf7gyc7fy65";
|
|
})
|
|
];
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
mailserver = {
|
|
enable = true;
|
|
fqdn = "mail.${cfg.domaine}";
|
|
domains = [ cfg.domaine ];
|
|
|
|
# A list of all login accounts. To create the password hashes, use
|
|
# mkpasswd -m sha-512 "super secret password"
|
|
loginAccounts = {
|
|
"paul@${cfg.domaine}" = {
|
|
hashedPassword = "$6$8wWQbtqVqUoH8$pQKg0bZPcjCbuPvyhjJ1lQy949M/AgfmAye/hDEIVUnCfwtlUxC1yj8CBHpNKeiiXhd8IUqk9r0/IJNvB6okf0";
|
|
};
|
|
};
|
|
|
|
# Certificate setup
|
|
certificateScheme = 1;
|
|
certificateFile = "/var/lib/acme/${cfg.domaine}/fullchain.pem";
|
|
keyFile = "/var/lib/acme/${cfg.domaine}/key.pem";
|
|
|
|
# Enable IMAP and POP3
|
|
enableImap = true;
|
|
enablePop3 = true;
|
|
enableImapSsl = true;
|
|
enablePop3Ssl = true;
|
|
|
|
# Enable the ManageSieve protocol
|
|
enableManageSieve = true;
|
|
};
|
|
|
|
security.acme.certs = {
|
|
"${cfg.domaine}" = {
|
|
extraDomains = {
|
|
"mail.${cfg.domaine}" = null;
|
|
};
|
|
postRun = ''
|
|
systemctl reload dovecot2.service
|
|
'';
|
|
};
|
|
};
|
|
|
|
};
|
|
}
|