nixfiles/hosts/hetzner-arm/containers/mail/mail.nix

96 lines
1.7 KiB
Nix
Raw Normal View History

2023-08-09 15:11:04 +01:00
{
2023-09-18 03:56:58 +01:00
self,
2023-08-09 15:11:04 +01:00
tree,
lib,
inputs,
config,
pkgs,
2023-08-09 15:11:04 +01:00
...
}: let
inherit (lib.modules) mkMerge mkForce;
2024-07-24 14:32:44 +01:00
inherit (lib.lists) flatten;
2023-09-18 03:56:58 +01:00
2023-08-09 15:11:04 +01:00
ports = [
# SMTP
25
# Submission
587
# Submission w/ SSL
465
# IMAP
143
# IMAP w/ SSL
993
# Sieve
4190
];
2023-09-18 03:56:58 +01:00
sharedFiles = [
2023-08-09 15:11:04 +01:00
"/var/lib/acme/mail.owo.monster/fullchain.pem"
"/var/lib/acme/mail.owo.monster/key.pem"
];
in {
containers.mail = {
autoStart = true;
2023-08-09 20:53:22 +01:00
bindMounts = mkMerge (map (file: {
2023-08-09 15:11:04 +01:00
"${file}" = {
hostPath = "${file}";
};
})
sharedFiles);
2023-08-09 15:11:04 +01:00
specialArgs = {
inherit inputs;
inherit tree;
2023-09-18 03:56:58 +01:00
inherit self;
};
config = {...}: {
nixpkgs.pkgs = pkgs;
2023-08-09 15:11:04 +01:00
2024-07-24 14:32:44 +01:00
imports = flatten (with tree; [
presets.nixos.containerBase
2023-08-09 15:11:04 +01:00
2024-07-24 14:32:44 +01:00
(with hosts.hetzner-arm.containers.mail; [
modules.mailserver
2023-10-16 18:17:28 +01:00
2023-08-09 15:11:04 +01:00
profiles.mailserver
profiles.restic
2024-07-24 14:32:44 +01:00
])
./secrets.nix
]);
2023-08-09 15:11:04 +01:00
systemd.tmpfiles.rules = [
"d /var/lib/acme - root root"
"d /var/lib/acme/mail.owo.monster - root root"
];
networking.firewall = {
enable = mkForce false;
2023-08-09 15:11:04 +01:00
};
home-manager.users.root.home.stateVersion = "24.05";
system.stateVersion = "24.05";
2023-08-09 15:11:04 +01:00
};
};
# ssl for mail
services.nginx = {
enable = true;
virtualHosts."mail.owo.monster" = {
serverName = "mail.owo.monster";
serverAliases = ["owo.monster"];
forceSSL = true;
enableACME = true;
acmeRoot = "/var/lib/acme/acme-challenge";
};
};
2023-08-09 20:53:22 +01:00
networking.firewall = {
allowedTCPPorts = ports;
allowedUDPPorts = ports;
};
2023-08-09 15:11:04 +01:00
}