From e862324afa0d294e0f4de7be9379490b2a8a50cc Mon Sep 17 00:00:00 2001 From: ibizaman Date: Sat, 8 Oct 2022 23:53:35 -0700 Subject: [PATCH] preliminary changes for password file in postgres --- postgresdb/default.nix | 17 +++++++++++++---- postgresdb/mkdefault.nix | 10 +++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/postgresdb/default.nix b/postgresdb/default.nix index b7678a0..0e3e0db 100644 --- a/postgresdb/default.nix +++ b/postgresdb/default.nix @@ -1,8 +1,17 @@ -{ stdenv, pkgs }: -{ postgresUsername -, postgresPassword -, postgresDatabase +{ stdenv +, pkgs +, lib }: +{ postgresDatabase +, postgresUsername +, postgresPassword ? null +, postgresPasswordFile ? null +}: + +assert lib.assertMsg ( + (postgresPassword == null && postgresPasswordFile != null) + || (postgresPassword != null && postgresPasswordFile == null) +) "set either postgresPassword or postgresPasswordFile"; # From https://github.com/svanderburg/dysnomia/blob/master/dysnomia-modules/postgresql-database.in # and https://github.com/svanderburg/dysnomia/blob/master/tests/deployment/postgresql-database.nix diff --git a/postgresdb/mkdefault.nix b/postgresdb/mkdefault.nix index ffff2b8..e2d7a08 100644 --- a/postgresdb/mkdefault.nix +++ b/postgresdb/mkdefault.nix @@ -1,18 +1,22 @@ { PostgresDB }: { name -, username -, password , database +, username +, password ? null +, passwordFile ? null , dependsOn ? {} }: { inherit name; + inherit database username password passwordFile; + pkg = PostgresDB { + postgresDatabase = database; postgresUsername = username; postgresPassword = password; - postgresDatabase = database; + postgresPasswordFile = passwordFile; }; inherit dependsOn;