Simplify mail server setup for test environment

This commit is contained in:
Jonas Heinrich 2023-04-12 14:30:54 +02:00
parent 910f5a493f
commit 91c0fa4228
2 changed files with 13 additions and 29 deletions

View file

@ -1,8 +1,7 @@
{ {
inputs = { inputs = {
# FIXME # FIXME: Switch to 23.05 when released
#inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:onny/nixpkgs/phpunit";
# Required for multi platform support # Required for multi platform support
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };

View file

@ -16,7 +16,7 @@
]; ];
imports = [ imports = [
./nextcloud.nix ./nextcloud.nix
"${fetchTarball "https://github.com/NixOS/nixpkgs/archive/master.tar.gz"}/nixos/modules/services/mail/maddy.nix" "${fetchTarball "https://github.com/onny/nixpkgs/archive/maddy-creds.tar.gz"}/nixos/modules/services/mail/maddy.nix"
]; ];
nixpkgs = { nixpkgs = {
@ -141,7 +141,12 @@
enable = true; enable = true;
hostname = "localhost"; hostname = "localhost";
primaryDomain = "localhost"; primaryDomain = "localhost";
localDomains = [ "$(primary_domain)" "10.0.2.0/24" "127.0.0.1" ]; localDomains = [
"$(primary_domain)"
"10.0.2.0/24"
"10.100.100.1"
"127.0.0.1"
];
# Disable any sender validation checks # Disable any sender validation checks
config = lib.concatStrings ( config = lib.concatStrings (
builtins.match "(.*)authorize_sender.*identity\n[ ]+\}(.*)" options.services.maddy.config.default builtins.match "(.*)authorize_sender.*identity\n[ ]+\}(.*)" options.services.maddy.config.default
@ -151,6 +156,10 @@
"user2@localhost" "user2@localhost"
"admin@localhost" "admin@localhost"
]; ];
ensureCredentials = [
"user1@localhost".passwordFile = "${pkgs.writeText "password" "test123"}";
"user2@localhost".passwordFile = "${pkgs.writeText "password" "test123"}";
"admin@localhost".passwordFile = "${pkgs.writeText "password" "test123"}";
}; };
# Configure local mail delivery # Configure local mail delivery
@ -167,30 +176,6 @@
}; };
}; };
# Creating mail users and inboxes
# FIXME: Upstream
systemd.services.maddy-accounts = {
script = ''
#!${pkgs.runtimeShell}
if ! ${pkgs.maddy}/bin/maddyctl creds list | grep "user1@localhost"; then
${pkgs.maddy}/bin/maddyctl creds create --password test123 user1@localhost
fi
if ! ${pkgs.maddy}/bin/maddyctl creds list | grep "user2@localhost"; then
${pkgs.maddy}/bin/maddyctl creds create --password test123 user2@localhost
fi
if ! ${pkgs.maddy}/bin/maddyctl creds list | grep "admin@localhost"; then
${pkgs.maddy}/bin/maddyctl creds create --password test123 admin@localhost
fi
'';
serviceConfig = {
Type = "oneshot";
User= "maddy";
};
after = [ "maddy.service" ];
wantedBy = [ "multi-user.target" ];
};
# Creating Nextcloud users and configure mail adresses # Creating Nextcloud users and configure mail adresses
systemd.services.nextcloud-add-user = { systemd.services.nextcloud-add-user = {
script = '' script = ''