From 8d4a7f780c83ede3d655ecc0e670d8c756b3105c Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Thu, 4 Apr 2024 17:44:09 -0400 Subject: [PATCH] postgres: Ensure creation of database users This is just a proof of concept that I plan to integrate into NixOS containers running specific users. The ensureDBOwnership part would no longer be needed since each database would receive its own container and consequently user. --- modules/postgres.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/postgres.nix b/modules/postgres.nix index afa92501..b1e5f593 100644 --- a/modules/postgres.nix +++ b/modules/postgres.nix @@ -1,7 +1,23 @@ { pkgs, ... }: { - services.postgresql.enable = true; + services.postgresql = { + enable = true; + + ensureUsers = [ + { + name = "user"; + } + { + name = "cooldbname"; + ensureDBOwnership = true; + } + ]; + + ensureDatabases = [ + "cooldbname" + ]; + }; environment.systemPackages = with pkgs; [ pgcli