From 77e16c0f76fff187085b3fb3f7e5d73e365f5845 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Sun, 5 Nov 2023 15:47:13 -0800 Subject: [PATCH] fix conflicting options in postgresql service --- modules/postgresql.nix | 2 +- test/modules/postgresql.nix | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/postgresql.nix b/modules/postgresql.nix index db07d43..f170c43 100644 --- a/modules/postgresql.nix +++ b/modules/postgresql.nix @@ -50,7 +50,7 @@ in }; dbConfig = passwordCfgs: { - services.postgresql.enable = (builtins.length passwordCfgs) > 0; + services.postgresql.enable = lib.mkDefault ((builtins.length passwordCfgs) > 0); services.postgresql.ensureDatabases = map ({ database, ... }: database) passwordCfgs; services.postgresql.ensureUsers = map ({ username, database, ... }: { name = username; diff --git a/test/modules/postgresql.nix b/test/modules/postgresql.nix index 22e9860..522d70c 100644 --- a/test/modules/postgresql.nix +++ b/test/modules/postgresql.nix @@ -36,6 +36,20 @@ in expr = testConfig {}; }; + testPostgresManualOptions = { + expected = { + services.postgresql = { + enable = true; + ensureUsers = []; + ensureDatabases = []; + }; + systemd.services.postgresql.postStart = ""; + }; + expr = testConfig { + services.postgresql.enable = true; + }; + }; + testPostgresOneWithoutPassword = { expected = { services.postgresql = {