Skip to content

Commit ebed5ff

Browse files
committed
nix: Fix PostgreSQL init role issues in process-compose setup
Create a dummy 'postgres' role to silence the "role postgres does not exist" log spam, and set PGUSER environment variable on init processes so psql connects as the OS user (matching what initdb created).
1 parent 4db9be2 commit ebed5ff

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

flake.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
inherit port dataDir;
9191
initialScript = {
9292
before = ''
93+
CREATE ROLE postgres WITH LOGIN;
9394
CREATE USER \"${user}\" WITH PASSWORD '${password}' SUPERUSER;
9495
'';
9596
};
@@ -140,6 +141,11 @@
140141
database = "graph-test";
141142
};
142143

144+
# Set PGUSER so psql connects as the OS user (matching initdb's superuser)
145+
settings.processes."postgres-unit-init".environment = {
146+
PGUSER = builtins.getEnv "USER";
147+
};
148+
143149
services.ipfs."ipfs-unit" = {
144150
enable = true;
145151
dataDir = "./.data/unit/ipfs";
@@ -172,6 +178,11 @@
172178
database = "graph-node";
173179
};
174180

181+
# Set PGUSER so psql connects as the OS user (matching initdb's superuser)
182+
settings.processes."postgres-integration-init".environment = {
183+
PGUSER = builtins.getEnv "USER";
184+
};
185+
175186
services.ipfs."ipfs-integration" = {
176187
enable = true;
177188
dataDir = "./.data/integration/ipfs";

0 commit comments

Comments
 (0)