Started working on mail server

This commit is contained in:
Jurn Wubben 2025-06-11 12:05:45 +02:00
parent 7d0e799e8f
commit 500ed29f42
7 changed files with 103 additions and 3 deletions

View file

@ -1,4 +1,4 @@
{lib, ...}: {
imports = [./caddy.nix ./transfer-sh.nix ./seafile.nix ./bot.nix ./immich.nix ./matrix.nix];
imports = [./caddy.nix ./transfer-sh.nix ./seafile.nix ./bot.nix ./immich.nix ./matrix.nix ./mail.nix];
options.niksos.server = lib.mkEnableOption "server servcies (such as caddy)."; #TODO: per service option.
}

87
system/server/mail.nix Normal file
View file

@ -0,0 +1,87 @@
{config, ...}: {
services.stalwart-mail = {
enable = true;
openFirewall = true;
settings = {
server = {
hostname = "mx1.jsw.tf";
tls = {
enable = true;
implicit = true;
};
listener = {
smtp = {
protocol = "smtp";
bind = "[::]:25";
};
submissions = {
bind = "[::]:465";
protocol = "smtp";
};
imaps = {
bind = "[::]:993";
protocol = "imap";
};
jmap = {
bind = "[::]:8080";
url = "https://mail.jsw.tf";
protocol = "jmap";
};
management = {
bind = ["127.0.0.1:8080"];
protocol = "http";
};
};
};
lookup.default = {
hostname = "mx1.jsw.tf";
domain = "jsw.tf";
};
acme."letsencrypt" = {
directory = "https://acme-v02.api.letsencrypt.org/directory";
challenge = "dns-01";
contact = "jswmail@proton.me";
domains = ["jsw.tf" "mx1.jsw.tf"];
provider = "cloudflare";
secret = "%{file:${config.age.secrets.cloudflare-acme.path}}%";
};
session.auth = {
mechanisms = "[plain]";
directory = "'in-memory'";
};
storage.directory = "in-memory";
session.rcpt.directory = "'in-memory'";
queue.outbound.next-hop = "'local'";
directory."imap".lookup.domains = ["jsw.tf"];
# directory."in-memory" = {
# type = "memory";
# principals = [
# {
# class = "individual";
# name = "User 1";
# secret = "%{file:/etc/stalwart/mail-pw1}%";
# email = [""];
# }
# ];
# };
authentication.fallback-admin = {
user = "admin";
secret = "%{file:${config.age.secrets.password.path}}%";
};
};
};
services.caddy.virtualHosts = {
"webadmin.jsw.tf" = {
extraConfig = ''
reverse_proxy http://127.0.0.1:8080
'';
serverAliases = [
"mta-sts.example.org"
"autoconfig.example.org"
"autodiscover.example.org"
"mail.example.org"
];
};
};
}

View file

@ -6,7 +6,7 @@
}: {
services.seafile = {
enable = config.niksos.server;
seahubPackage = inputs.nixpkgs-stable.legacyPackages.${pkgs.system}.seahub;
seahubPackage = inputs.nixpkgs.legacyPackages.${pkgs.system}.seahub;
adminEmail = "jurnwubben@gmail.com";
initialAdminPassword = "ChangeMeTheFuckNow!";