From 91c0fa42288764260905a142bca1c0170208bd49 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Wed, 12 Apr 2023 14:30:54 +0200 Subject: [PATCH] Simplify mail server setup for test environment --- flake.nix | 5 ++--- vm-nextcloud.nix | 37 +++++++++++-------------------------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/flake.nix b/flake.nix index 4efa986..791f803 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,7 @@ { inputs = { - # FIXME - #inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; - nixpkgs.url = "github:onny/nixpkgs/phpunit"; + # FIXME: Switch to 23.05 when released + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # Required for multi platform support flake-utils.url = "github:numtide/flake-utils"; }; diff --git a/vm-nextcloud.nix b/vm-nextcloud.nix index 3dde283..7e12105 100644 --- a/vm-nextcloud.nix +++ b/vm-nextcloud.nix @@ -16,7 +16,7 @@ ]; imports = [ ./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 = { @@ -141,7 +141,12 @@ enable = true; hostname = "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 config = lib.concatStrings ( builtins.match "(.*)authorize_sender.*identity\n[ ]+\}(.*)" options.services.maddy.config.default @@ -151,6 +156,10 @@ "user2@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 @@ -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 systemd.services.nextcloud-add-user = { script = ''