From a456da3490fc245c908654d6efed64a78b67763e Mon Sep 17 00:00:00 2001 From: K900 Date: Thu, 16 Feb 2023 19:11:10 +0300 Subject: nixos/tests/pass-secret-service: fix eval --- nixos/tests/pass-secret-service.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos/tests') diff --git a/nixos/tests/pass-secret-service.nix b/nixos/tests/pass-secret-service.nix index a85a508bfe16b..e0dddf0ad29e2 100644 --- a/nixos/tests/pass-secret-service.nix +++ b/nixos/tests/pass-secret-service.nix @@ -1,6 +1,6 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { name = "pass-secret-service"; - meta.maintainers = with lib; [ aidalgol ]; + meta.maintainers = [ lib.maintainers.aidalgol ]; nodes.machine = { nodes, pkgs, ... }: { -- cgit 1.4.1 From 84434922bcb77dda8bdde7818276dc730cfc0af0 Mon Sep 17 00:00:00 2001 From: K900 Date: Thu, 16 Feb 2023 19:11:19 +0300 Subject: nixos/tests/quake3: fix eval --- nixos/tests/quake3.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nixos/tests') diff --git a/nixos/tests/quake3.nix b/nixos/tests/quake3.nix index 82af1af463d03..ef5fcc41476bc 100644 --- a/nixos/tests/quake3.nix +++ b/nixos/tests/quake3.nix @@ -1,4 +1,4 @@ -import ./make-test-python.nix ({ pkgs, ...} : +import ./make-test-python.nix ({ pkgs, lib, ...} : let @@ -11,9 +11,9 @@ let }; # Only allow the demo data to be used (only if it's unfreeRedistributable). - unfreePredicate = pkg: with pkgs.lib; let + unfreePredicate = pkg: with lib; let allowPackageNames = [ "quake3-demodata" "quake3-pointrelease" ]; - allowLicenses = [ pkgs.lib.licenses.unfreeRedistributable ]; + allowLicenses = [ lib.licenses.unfreeRedistributable ]; in elem pkg.pname allowPackageNames && elem (pkg.meta.license or null) allowLicenses; @@ -31,7 +31,7 @@ in rec { name = "quake3"; - meta = with pkgs.stdenv.lib.maintainers; { + meta = with lib.maintainers; { maintainers = [ domenkozar eelco ]; }; -- cgit 1.4.1 From 13ff144c70351811141067d6e77b599e146e44b2 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Thu, 16 Feb 2023 22:47:11 +0100 Subject: nixos/maddy: Add option ensureAccounts --- nixos/modules/services/mail/maddy.nix | 51 ++++++++++++++++++++++++++++++----- nixos/tests/maddy.nix | 2 +- 2 files changed, 45 insertions(+), 8 deletions(-) (limited to 'nixos/tests') diff --git a/nixos/modules/services/mail/maddy.nix b/nixos/modules/services/mail/maddy.nix index eeb113e204c6e..5f3a9b56292d2 100644 --- a/nixos/modules/services/mail/maddy.nix +++ b/nixos/modules/services/mail/maddy.nix @@ -223,22 +223,59 @@ in { ''; }; + ensureAccounts = mkOption { + type = types.listOf types.str; + default = []; + description = lib.mdDoc '' + List of IMAP accounts which get automatically created. Note that for + a complete setup, user credentials for these accounts are required too + and can be created using the command `maddyctl creds`. + This option does not delete accounts which are not (anymore) listed. + ''; + example = [ + "user1@localhost" + "user2@localhost" + ]; + }; + }; }; config = mkIf cfg.enable { systemd = { + packages = [ pkgs.maddy ]; - services.maddy = { - serviceConfig = { - User = cfg.user; - Group = cfg.group; - StateDirectory = [ "maddy" ]; + services = { + maddy = { + serviceConfig = { + User = cfg.user; + Group = cfg.group; + StateDirectory = [ "maddy" ]; + }; + restartTriggers = [ config.environment.etc."maddy/maddy.conf".source ]; + wantedBy = [ "multi-user.target" ]; + }; + maddy-ensure-accounts = { + script = '' + ${optionalString (cfg.ensureAccounts != []) '' + ${concatMapStrings (account: '' + if ! ${pkgs.maddy}/bin/maddyctl imap-acct list | grep "${account}"; then + ${pkgs.maddy}/bin/maddyctl imap-acct create ${account} + fi + '') cfg.ensureAccounts} + ''} + ''; + serviceConfig = { + Type = "oneshot"; + User= "maddy"; + }; + after = [ "maddy.service" ]; + wantedBy = [ "multi-user.target" ]; }; - restartTriggers = [ config.environment.etc."maddy/maddy.conf".source ]; - wantedBy = [ "multi-user.target" ]; + }; + }; environment.etc."maddy/maddy.conf" = { diff --git a/nixos/tests/maddy.nix b/nixos/tests/maddy.nix index b9d0416482da1..800d254f17704 100644 --- a/nixos/tests/maddy.nix +++ b/nixos/tests/maddy.nix @@ -9,6 +9,7 @@ import ./make-test-python.nix ({ pkgs, ... }: { hostname = "server"; primaryDomain = "server"; openFirewall = true; + ensureAccounts = [ "postmaster@server" ]; }; }; @@ -50,7 +51,6 @@ import ./make-test-python.nix ({ pkgs, ... }: { server.wait_for_open_port(587) server.succeed("maddyctl creds create --password test postmaster@server") - server.succeed("maddyctl imap-acct create postmaster@server") client.succeed("send-testmail") client.succeed("test-imap") -- cgit 1.4.1