Commit 3068e1207355

Vincent Demeester <vincent@sbr.pm>
2025-12-02 07:39:06
fix: Define PSQL variable in PostgreSQL postStart scripts
- Prevent script failures from undefined PSQL variable reference - Ensure correct psql binary path and port configuration - Fix Immich database ownership setup on aion and rhea hosts Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 6d9e5f9
Changed files (2)
systems
systems/aion/extra.nix
@@ -3,6 +3,7 @@
   globals,
   lib,
   pkgs,
+  config,
   ...
 }:
 {
@@ -35,6 +36,7 @@
 
   # Grant vincent ownership of the immich database and schemas
   systemd.services.postgresql.postStart = lib.mkAfter ''
+    PSQL="${config.services.postgresql.package}/bin/psql --port=${toString config.services.postgresql.settings.port}"
     $PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname = 'vincent'" | grep -q 1 || $PSQL -tAc "CREATE ROLE vincent WITH LOGIN"
     $PSQL -tAc "ALTER DATABASE immich OWNER TO vincent"
     $PSQL immich -tAc "ALTER SCHEMA public OWNER TO vincent"
systems/rhea/extra.nix
@@ -477,6 +477,7 @@
 
   # Grant vincent ownership of the immich database and schemas
   systemd.services.postgresql.postStart = lib.mkAfter ''
+    PSQL="${config.services.postgresql.package}/bin/psql --port=${toString config.services.postgresql.settings.port}"
     $PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname = 'vincent'" | grep -q 1 || $PSQL -tAc "CREATE ROLE vincent WITH LOGIN"
     $PSQL -tAc "ALTER DATABASE immich OWNER TO vincent"
     $PSQL immich -tAc "ALTER SCHEMA public OWNER TO vincent"