From 4d38f037181db14afbe71e34f77eb095c089bba7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 24 Aug 2025 18:36:19 +0200 Subject: [PATCH] feat(server/mail): adding mail configuration for enium mailing - working but not with my current configuration... - have to see how to fix the issues with the freebox (not allowed to touch the port 25) --- flake.nix | 4 +++- hosts/server/configuration.nix | 1 + services/self_host.nix | 9 ++++++++ services/self_host/mail.nix | 42 ++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 services/self_host/mail.nix diff --git a/flake.nix b/flake.nix index 6eb8023..6033c60 100644 --- a/flake.nix +++ b/flake.nix @@ -7,11 +7,12 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver"; minecraft.url = "github:Infinidoge/nix-minecraft"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs, flake-utils, ... }@inputs: + outputs = { self, nixpkgs, flake-utils, simple-nixos-mailserver, ... }@inputs: let pkgs = import nixpkgs { config.allowUnfree = true; @@ -31,6 +32,7 @@ system = "x86_64-linux"; modules = [ ./hosts/server/configuration.nix + simple-nixos-mailserver.nixosModule ]; specialArgs = { inherit inputs; diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix index 69dd3d0..e9b5a30 100644 --- a/hosts/server/configuration.nix +++ b/hosts/server/configuration.nix @@ -23,6 +23,7 @@ selfhost = { htop = true; ollama = false; + mail = false; monitor = true; teamspeak = true; nextcloud = true; diff --git a/services/self_host.nix b/services/self_host.nix index 86e423c..b87de96 100644 --- a/services/self_host.nix +++ b/services/self_host.nix @@ -4,6 +4,9 @@ let htop = import ./self_host/htop.nix { inherit inputs config pkgs lib; }; + mail = import ./self_host/mail.nix { + inherit inputs config pkgs lib; + }; monitor = import ./self_host/monitor.nix { inherit inputs config pkgs lib; }; @@ -21,6 +24,7 @@ in { imports = [ nextcloud + mail htop ollama teamspeak @@ -48,6 +52,11 @@ in default = false; description = "Enable the ollama"; }; + mail = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable the mail"; + }; monitor = lib.mkOption { type = lib.types.bool; default = false; diff --git a/services/self_host/mail.nix b/services/self_host/mail.nix new file mode 100644 index 0000000..cc1153e --- /dev/null +++ b/services/self_host/mail.nix @@ -0,0 +1,42 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.service.selfhost.mail; +in +{ + config = lib.mkIf cfg { + services.rspamd.enable = true; + mailserver = { + enable = true; + stateVersion = 3; + fqdn = "mail.enium.eu"; + domains = [ + "enium.eu" + ]; + loginAccounts = { + "no-reply@enium.eu" = { + hashedPasswordFile = "/root/mail-passwd.txt"; + }; + }; + certificateScheme = "acme-nginx"; + }; + + services = { + roundcube = { + enable = true; + hostName = "mail.enium.eu"; + extraConfig = '' + $config['smtp_host'] = "tls://mail.enium.eu"; + $config['smtp_user'] = "%u"; + $config['smtp_pass'] = "%p"; + ''; + }; + nginx = { + virtualHosts."mail.enium.eu" = { + forceSSL = true; + enableACME = true; + }; + }; + }; + }; +}