fix nix code

This commit is contained in:
2025-03-17 16:00:24 +04:00
parent 2ace2216dd
commit 2c3bd39a7e

16
lib.nix
View File

@@ -108,13 +108,15 @@ in
)
);
};
setupInitialDatabases = if initialDatabases != [] then (
lib.concatMapStrings (db: ''
echo "Checking presence of database ${db.name}"
dbAlreadyExists="$(echo "SELECT 1 AS result FROM pg_database WHERE datname='${db.name}';" | psql --dbname postgres | ${pkgs.gnugrep}/bin/grep -c 'exists = "1"' || true)"
echo $dbAlreadyExists
'') initialDatabases
);
setupInitialDatabases =
if initialDatabases != [ ] then
(lib.concatMapStrings (db: ''
echo "Checking presence of database ${db.name}"
dbAlreadyExists="$(echo "SELECT 1 AS result FROM pg_database WHERE datname='${db.name}';" | psql --dbname postgres | ${pkgs.gnugrep}/bin/grep -c 'exists = "1"' || true)"
echo $dbAlreadyExists
'') initialDatabases)
else
"";
setupScript = pkgs.writeShellApplication {
name = "setup-postgres";
runtimeInputs = [