feat(postgresql): consolidate database and role-password boilerplate on Vega (#274) #287

Merged
nimmo merged 3 commits from feat/issue-274-consolidate-postgresql-boilerplate into main 2026-10-08 15:48:08 +01:00
Owner

Context

Ref #274 (Milestone: Nix Idioms and Architecture Hygiene)

In hosts/vega/databases/ and modules/databases/immich.nix, several services repeated ~50-line oneshot systemd services executing ALTER ROLE <name> WITH LOGIN PASSWORD '$password' and database ownership queries. Additionally, standalone single-database definitions (atticd.nix, forgejo.nix, metamcp.nix, openwebui.nix, postgres.nix) existed as tiny 3-line files doing nothing other than appending to services.postgresql.ensureDatabases.

Changes

  • Reusable Role Passwords Module (modules/databases/postgresql-role-password.nix):
    • Implements declarative services.postgresql.rolePasswords.<name> submodule option.
    • Automatically provisions the SOPS secret (owner = "postgres:postgres", mode 0400, with restartUnits = [ "postgresql-set-<name>-password.service" ]).
    • Automatically appends to services.postgresql.ensureDatabases and services.postgresql.ensureUsers.
    • Generates idempotent oneshot systemd unit postgresql-set-<name>-password (ordered after and requiring postgresql-setup.service) that runs ALTER ROLE ... WITH LOGIN PASSWORD ...; and ALTER DATABASE ... OWNER TO ...; via psql <<SQL stdin.
    • Registers units with services.serviceFailureMonitor.services.
  • Application Migrations:
    • Migrated modules/databases/immich.nix to use rolePasswords.immich.
    • Migrated hosts/vega/databases/ (freshrss.nix, paperless.nix, radarr.nix, sonarr.nix, whisparr-v3.nix) to use declarative rolePasswords.
  • Consolidation & Cleanup:
    • Consolidated single-database stubs (atticd, forgejo, metamcp_db, openwebui, postgres) into hosts/vega/databases/postgresql.nix.
    • Deleted obsolete stub files (atticd.nix, forgejo.nix, metamcp.nix, openwebui.nix, postgres.nix).
    • Net reduction: -114 lines across 13 files.
  • Durable Memory:
    • Documented architecture in KiwiFS at pages/projects/nixos-config/postgresql-role-passwords.md.

Validation

  • nix flake check passed cleanly (all checks passed! flake check OK, including formatting and service-failure-monitor-coverage).
  • Vega database evaluation verified:
    • ensureDatabases contains all 14 expected databases: freshrss, immich, paperless, radarr-log, radarr-main, sonarr-log, sonarr-main, whisparr-v3-log, whisparr-v3-main, atticd, forgejo, metamcp_db, openwebui, postgres (identical set to pre-refactor baseline).
    • ensureUsers contains all 6 expected roles (freshrss, immich, paperless, radarr, sonarr, whisparr-v3), all with login = true.
    • Script output verified for psql <<SQL heredoc execution and robust quoting.
    • serviceFailureMonitor includes all 6 role-password units.
  • Fleet evaluation verified: toplevel derivations for electra, vega, lena, and lyra all evaluate and dry-run cleanly.
## Context Ref #274 (Milestone: Nix Idioms and Architecture Hygiene) In `hosts/vega/databases/` and `modules/databases/immich.nix`, several services repeated ~50-line oneshot systemd services executing `ALTER ROLE <name> WITH LOGIN PASSWORD '$password'` and database ownership queries. Additionally, standalone single-database definitions (`atticd.nix`, `forgejo.nix`, `metamcp.nix`, `openwebui.nix`, `postgres.nix`) existed as tiny 3-line files doing nothing other than appending to `services.postgresql.ensureDatabases`. ## Changes - **Reusable Role Passwords Module (`modules/databases/postgresql-role-password.nix`)**: - Implements declarative `services.postgresql.rolePasswords.<name>` submodule option. - Automatically provisions the SOPS secret (`owner = "postgres:postgres"`, mode `0400`, with `restartUnits = [ "postgresql-set-<name>-password.service" ]`). - Automatically appends to `services.postgresql.ensureDatabases` and `services.postgresql.ensureUsers`. - Generates idempotent oneshot systemd unit `postgresql-set-<name>-password` (ordered after and requiring `postgresql-setup.service`) that runs `ALTER ROLE ... WITH LOGIN PASSWORD ...;` and `ALTER DATABASE ... OWNER TO ...;` via `psql <<SQL` stdin. - Registers units with `services.serviceFailureMonitor.services`. - **Application Migrations**: - Migrated `modules/databases/immich.nix` to use `rolePasswords.immich`. - Migrated `hosts/vega/databases/` (`freshrss.nix`, `paperless.nix`, `radarr.nix`, `sonarr.nix`, `whisparr-v3.nix`) to use declarative `rolePasswords`. - **Consolidation & Cleanup**: - Consolidated single-database stubs (`atticd`, `forgejo`, `metamcp_db`, `openwebui`, `postgres`) into `hosts/vega/databases/postgresql.nix`. - Deleted obsolete stub files (`atticd.nix`, `forgejo.nix`, `metamcp.nix`, `openwebui.nix`, `postgres.nix`). - Net reduction: -114 lines across 13 files. - **Durable Memory**: - Documented architecture in KiwiFS at `pages/projects/nixos-config/postgresql-role-passwords.md`. ## Validation - `nix flake check` passed cleanly (`all checks passed! flake check OK`, including `formatting` and `service-failure-monitor-coverage`). - Vega database evaluation verified: - `ensureDatabases` contains all 14 expected databases: `freshrss`, `immich`, `paperless`, `radarr-log`, `radarr-main`, `sonarr-log`, `sonarr-main`, `whisparr-v3-log`, `whisparr-v3-main`, `atticd`, `forgejo`, `metamcp_db`, `openwebui`, `postgres` (identical set to pre-refactor baseline). - `ensureUsers` contains all 6 expected roles (`freshrss`, `immich`, `paperless`, `radarr`, `sonarr`, `whisparr-v3`), all with `login = true`. - Script output verified for `psql <<SQL` heredoc execution and robust quoting. - `serviceFailureMonitor` includes all 6 role-password units. - Fleet evaluation verified: toplevel derivations for `electra`, `vega`, `lena`, and `lyra` all evaluate and dry-run cleanly.
feat(postgresql): consolidate database and role-password boilerplate on Vega (#274)
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 1m35s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 12m33s
4119ba3c28
- Add modules/databases/postgresql-role-password.nix introducing
  declarative services.postgresql.rolePasswords.<name> option.
- Automatically provision SOPS secret, ensureUsers, ensureDatabases,
  oneshot password-setting systemd unit, and serviceFailureMonitor entry.
- Migrate Paperless, FreshRSS, Radarr, Sonarr, Whisparr V3, and Immich
  database configurations to use the declarative rolePasswords option.
- Consolidate trivial standalone ensureDatabases files (atticd, forgejo,
  metamcp, openwebui, postgres) into hosts/vega/databases/postgresql.nix.
- Remove ~200 lines of repetitive oneshot shell script boilerplate.
clankbot left a comment

Automated code review

Reviewed commit: 4119ba3c28a0d046dba4b44289270016439f6d5b

Verdict: Ready to merge

No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory.

Overall assessment

Reviewed the PostgreSQL role-password consolidation (new modules/databases/postgresql-role-password.nix, six migrated consumers, and the merged hosts/vega/databases/postgresql.nix) against the checked-out tree. Cross-checks passed: the five deleted stubs (atticd, forgejo, metamcp, openwebui, postgres) are no imported anywhere (hosts/vega/databases/postgresql.nix re-lists all five names in ensureDatabases), no file still references the removed sops.secrets attribute names (*-db-password-postgres, radarr-db-password, immich-db-password-postgres, ...) — the app-level secrets in modules/services/{freshrss,paperless,bookstack,immich}.nix use distinct names and are untouched — and the generated unit names (postgresql-set-<name>-password) match the names added to services.serviceFailureMonitor.services by the same module. One latent defect in the new module's generated shell script is reported; the remaining observations are questions about evaluation-time merging and unit ordering that cannot be settled from the supplied material.

Blocking findings

None.

Important findings

None.

Suggestions

  • Generated unit emits an unterminated psql heredoc when databases is empty or ensureDBOwnership = false (modules/databases/postgresql-role-password.nix:164; high confidence)
    The generated script ends with --variable=ON_ERROR_STOP=1 <<SQL (line 162) and the terminator is appended to an interpolated value: ${alterDatabasesCmd}SQL (line 164), inside an indented string whose closing '' is indented two columns less than the body, so the emitted script keeps two leading spaces on that line. alterDatabasesCmd (line 136) is "" when roleCfg.databases == [ ] — the documented default for the databases option — or when ensureDBOwnership = false, so the terminator line becomes SQL, which is not a valid terminator for an unquoted <<SQL heredoc; bash then reads to EOF and fails with a syntax error. The six current call sites all pass a non-empty databases list, whose trailing \n puts SQL at column 1, so this does not affect the evaluated Vega config today.
    Impact: Any future or default use of the module (databases = [ ], or ensureDBOwnership = false on a role that does have databases) produces a postgresql-set-<name>-password oneshot that fails at start; because the module also adds that unit to services.serviceFailureMonitor.services, the failure would surface as a spurious runtime service failure instead of an evaluation-time configuration error.
    Suggested fix: Emit the terminator on its own unindented source line (build the SQL body as a separate string and interpolate it before a dedicated SQL line), or make alterDatabasesCmd always end with a newline and use ${alterDatabasesCmd}\nSQL, or reject databases == [ ] at evaluation time when the unit is generated.

Tests and validation

  • No configured deterministic checks.

Questions

  • hosts/vega/default.nix imports ../../modules/databases/immich.nix (which now declares imports = [ ./postgresql-role-password.nix ]) and ./databases/postgresql.nix (which imports the same file directly), so the module is reachable twice on Vega. Please confirm the evaluated config does not duplicate the services.postgresql.rolePasswords option definition or double the entries contributed to services.postgresql.ensureDatabases and services.postgresql.ensureUsers (list-typed options merge by concatenation); the PR's reported ensureDatabases being a set would not reveal duplicated list entries.
  • Ownership for freshrss, paperless and immich moved from the removed services.postgresql.ensureUsers[].ensureDBOwnership = true to ALTER DATABASE ... OWNER TO ... inside the generated oneshot, which is ordered only after postgresql-setup.service. Is it intended that the application services are not ordered after postgresql-set-<name>-password.service, so a consumer can start while the database owner is still postgres?
  • The installed SOPS secret paths change (e.g. freshrss-db-password-postgres -> postgresql-role-password-freshrss). I found no reference to the old names in this tree; please confirm no live container bind mount, backup include, or runbook outside the repository names the old paths.

Review limitations

  • No Nix toolchain is available in this container, so nix flake check, the repository's formatting/service-failure-monitor-coverage checks, and the evaluated ensureDatabases/ensureUsers/systemd.services values could not be re-derived; the PR's validation statements were treated as untrusted evidence.
  • No live host state was inspected: the generated systemd units, their start results, and the current PostgreSQL role/database ownership on Vega were not observed.
  • Shell behaviour of the generated psql <<SQL script (heredoc termination, indentation stripping of the Nix indented string, quoting of $password_sql) was inferred from the source text rather than executed.
  • No access was available to the KiwiFS page pages/projects/nixos-config/postgresql-role-passwords.md, the referenced issue #274, or the CI logs.

Diff coverage

  • hosts/vega/databases/atticd.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/forgejo.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/freshrss.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/metamcp.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/openwebui.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/paperless.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/postgres.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/postgresql.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/radarr.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/sonarr.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/whisparr-v3.nix: reviewed — included in a context-limited batch
  • modules/databases/immich.nix: reviewed — included in a context-limited batch
  • modules/databases/postgresql-role-password.nix: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 1
  • Previous automated review: none found
  • Findings: 1
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `4119ba3c28a0d046dba4b44289270016439f6d5b` ## Verdict: Ready to merge No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory. ### Overall assessment Reviewed the PostgreSQL role-password consolidation (new `modules/databases/postgresql-role-password.nix`, six migrated consumers, and the merged `hosts/vega/databases/postgresql.nix`) against the checked-out tree. Cross-checks passed: the five deleted stubs (`atticd`, `forgejo`, `metamcp`, `openwebui`, `postgres`) are no imported anywhere (`hosts/vega/databases/postgresql.nix` re-lists all five names in `ensureDatabases`), no file still references the removed `sops.secrets` attribute names (`*-db-password-postgres`, `radarr-db-password`, `immich-db-password-postgres`, ...) — the app-level secrets in `modules/services/{freshrss,paperless,bookstack,immich}.nix` use distinct names and are untouched — and the generated unit names (`postgresql-set-<name>-password`) match the names added to `services.serviceFailureMonitor.services` by the same module. One latent defect in the new module's generated shell script is reported; the remaining observations are questions about evaluation-time merging and unit ordering that cannot be settled from the supplied material. ### Blocking findings None. ### Important findings None. ### Suggestions - **Generated unit emits an unterminated psql heredoc when `databases` is empty or `ensureDBOwnership = false`** (modules/databases/postgresql-role-password.nix:164; high confidence) The generated `script` ends with `--variable=ON_ERROR_STOP=1 <<SQL` (line 162) and the terminator is appended to an interpolated value: ` ${alterDatabasesCmd}SQL` (line 164), inside an indented string whose closing `''` is indented two columns less than the body, so the emitted script keeps two leading spaces on that line. `alterDatabasesCmd` (line 136) is `""` when `roleCfg.databases == [ ]` — the documented default for the `databases` option — or when `ensureDBOwnership = false`, so the terminator line becomes ` SQL`, which is not a valid terminator for an unquoted `<<SQL` heredoc; bash then reads to EOF and fails with a syntax error. The six current call sites all pass a non-empty `databases` list, whose trailing `\n` puts `SQL` at column 1, so this does not affect the evaluated Vega config today. Impact: Any future or default use of the module (`databases = [ ]`, or `ensureDBOwnership = false` on a role that does have databases) produces a `postgresql-set-<name>-password` oneshot that fails at start; because the module also adds that unit to `services.serviceFailureMonitor.services`, the failure would surface as a spurious runtime service failure instead of an evaluation-time configuration error. Suggested fix: Emit the terminator on its own unindented source line (build the SQL body as a separate string and interpolate it before a dedicated `SQL` line), or make `alterDatabasesCmd` always end with a newline and use `${alterDatabasesCmd}\nSQL`, or reject `databases == [ ]` at evaluation time when the unit is generated. ### Tests and validation - No configured deterministic checks. ### Questions - `hosts/vega/default.nix` imports `../../modules/databases/immich.nix` (which now declares `imports = [ ./postgresql-role-password.nix ]`) and `./databases/postgresql.nix` (which imports the same file directly), so the module is reachable twice on Vega. Please confirm the evaluated config does not duplicate the `services.postgresql.rolePasswords` option definition or double the entries contributed to `services.postgresql.ensureDatabases` and `services.postgresql.ensureUsers` (list-typed options merge by concatenation); the PR's reported `ensureDatabases` being a set would not reveal duplicated list entries. - Ownership for `freshrss`, `paperless` and `immich` moved from the removed `services.postgresql.ensureUsers[].ensureDBOwnership = true` to `ALTER DATABASE ... OWNER TO ...` inside the generated oneshot, which is ordered only after `postgresql-setup.service`. Is it intended that the application services are not ordered after `postgresql-set-<name>-password.service`, so a consumer can start while the database owner is still `postgres`? - The installed SOPS secret paths change (e.g. `freshrss-db-password-postgres` -> `postgresql-role-password-freshrss`). I found no reference to the old names in this tree; please confirm no live container bind mount, backup include, or runbook outside the repository names the old paths. ### Review limitations - No Nix toolchain is available in this container, so `nix flake check`, the repository's formatting/service-failure-monitor-coverage checks, and the evaluated `ensureDatabases`/`ensureUsers`/`systemd.services` values could not be re-derived; the PR's validation statements were treated as untrusted evidence. - No live host state was inspected: the generated systemd units, their start results, and the current PostgreSQL role/database ownership on Vega were not observed. - Shell behaviour of the generated `psql <<SQL` script (heredoc termination, indentation stripping of the Nix indented string, quoting of `$password_sql`) was inferred from the source text rather than executed. - No access was available to the KiwiFS page `pages/projects/nixos-config/postgresql-role-passwords.md`, the referenced issue #274, or the CI logs. ### Diff coverage - `hosts/vega/databases/atticd.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/forgejo.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/freshrss.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/metamcp.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/openwebui.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/paperless.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/postgres.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/postgresql.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/radarr.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/sonarr.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/whisparr-v3.nix`: **reviewed** — included in a context-limited batch - `modules/databases/immich.nix`: **reviewed** — included in a context-limited batch - `modules/databases/postgresql-role-password.nix`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md - Commits considered: 1 - Previous automated review: none found - Findings: 1 </details>
fix(postgresql): ensure clean heredoc termination regardless of databases count
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 1m29s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 9m35s
77296f8eba
clankbot left a comment

Automated code review

Reviewed commit: 77296f8eba348a3f34f049988a90df41a72bcb6b

Verdict: Ready to merge

No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory.

Overall assessment

The PR replaces per-service PostgreSQL role/password boilerplate with a services.postgresql.rolePasswords submodule (modules/databases/postgresql-role-password.nix), migrates the six Vega role definitions (freshrss, paperless, radarr, sonarr, whisparr-v3) and modules/databases/immich.nix to it, and inlines the five role-less ensureDatabases entries (atticd, forgejo, metamcp_db, openwebui, postgres) into hosts/vega/databases/postgresql.nix. I verified in the checked-out tree that the deleted per-database files are no longer referenced from any host (only ./databases/postgresql.nix is imported, hosts/vega/default.nix:58), that no consumer still refers to the old secret attribute names (freshrss-db-password-postgres, radarr-db-password, immich-db-password-postgres, etc. return no matches; the unrelated freshrss-db-password/paperless-db-password/immich-db-password names in modules/services/* are distinct attributes that already existed before the change), that the new module import paths resolve (hosts/vega/databases/postgresql.nix:9 ../../../modules/databases/postgresql-role-password.nix, modules/databases/immich.nix ./postgresql-role-password.nix), and that the generated database lists do not overlap the explicit list in postgresql.nix. No test fixture in tests/ references PostgreSQL, so no repository rule requires added coverage. One concrete, evidence-backed defect remains: the submodule's ensureDBOwnership option is consumed only by the oneshot SQL generator and is never propagated into the generated services.postgresql.ensureUsers entries, so the evaluated NixOS output no longer matches the pre-refactor ensureUsers shape for freshrss, paperless, and immich.

Blocking findings

None.

Important findings

None.

Suggestions

  • Submodule option ensureDBOwnership is not propagated to the NixOS ensureUsers field it is named after (modules/databases/postgresql-role-password.nix:124; high confidence)
    The submodule declares ensureDBOwnership (line 68, default true, described as "Whether to grant ownership of specified databases to this role") and uses it only as a guard for the generated ALTER DATABASE "<db>" OWNER TO "<role>"; SQL in the oneshot (line 142). The services.postgresql.ensureUsers generation (lines 117-125) emits only name = roleCfg.role; and ensureClauses.login = roleCfg.login; — it never sets the NixOS ensureDBOwnership field. The diff shows the pre-refactor definitions did set it: hosts/vega/databases/freshrss.nix and hosts/vega/databases/paperless.nix each had ensureUsers = [ { name = <x>; ensureDBOwnership = true; } ];, and modules/databases/immich.nix had { name = "immich"; ensureDBOwnership = true; ensureClauses.login = true; }. Conversely, the generated entries now add ensureClauses.login = true for freshrss and paperless, which those files did not previously declare.
    Impact: The evaluated services.postgresql.ensureUsers output differs from the pre-refactor baseline for every migrated role: ensureDBOwnership is dropped and ensureClauses.login = true is added for freshrss and paperless. The end state is equivalent on a healthy boot because the oneshot (ordered after/requires postgresql-setup.service) now issues the ALTER DATABASE ... OWNER TO ... that NixOS previously issued during postgresql-setup.service, so this is not a demonstrated runtime regression. The concrete problem is the option contract: ensureDBOwnership shadows the NixOS field name but cannot control it, so the generated configuration is not the documented NixOS mechanism and a reader comparing this module against upstream services.postgresql.ensureUsers will be misled.
    Suggested fix: Either emit ensureDBOwnership = roleCfg.ensureDBOwnership; in the generated ensureUsers entry at line 124 so the option drives the NixOS field it is named after (and keep the oneshot ALTER DATABASE only when needed), or rename the submodule option (e.g. alterDatabaseOwnership) and state in its description that ownership is set by the generated oneshot rather than by postgresql-setup.service. Also make the login default explicit for freshrss/paperless if the added ensureClauses.login = true was not intended.

Tests and validation

  • No configured deterministic checks.

Questions

  • Was dropping ensureDBOwnership = true from the generated ensureUsers entries for freshrss, paperless, and immich deliberate (ownership delegated entirely to the oneshot), or should the submodule option also drive the NixOS field?
  • Is emitting ensureClauses.login = true for freshrss and paperless intended? Their pre-refactor ensureUsers entries declared only ensureDBOwnership, and the diff shows no ensureClauses for either.

Review limitations

  • I did not run nix flake check, just test, or evaluate the configuration, so I cannot independently confirm the PR's claim that the evaluated ensureDatabases/ensureUsers/failure-monitor sets match the pre-refactor baseline; the ensureUsers comparison above is read directly from the supplied diff and module source.
  • I did not inspect the upstream nixpkgs services.postgresql module source, so the exact runtime semantics of ensureUsers.ensureDBOwnership and ensureClauses.login, and whether services.postgresql accepts a new rolePasswords sub-attribute in this pinned nixpkgs, are taken from the field names visible in the diff and from the PR's reported passing nix flake check rather than from supplied upstream source.
  • I did not verify that the SOPS keys exist for the new secret attribute names (postgresql-role-password-<name>) or that .sops.yaml recipients cover them; the sopsFile/key values are unchanged by the diff and I did not decrypt or inspect secret values.
  • I did not exercise the generated systemd units or any deployment; runtime ordering, idempotency, and heredoc quoting behaviour of the generated psql ... <<SQL script are not verified by me, and I report no defect in them.

Diff coverage

  • hosts/vega/databases/atticd.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/forgejo.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/freshrss.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/metamcp.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/openwebui.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/paperless.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/postgres.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/postgresql.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/radarr.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/sonarr.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/whisparr-v3.nix: reviewed — included in a context-limited batch
  • modules/databases/immich.nix: reviewed — included in a context-limited batch
  • modules/databases/postgresql-role-password.nix: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 2
  • Previous automated review: none found
  • Findings: 1
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `77296f8eba348a3f34f049988a90df41a72bcb6b` ## Verdict: Ready to merge No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory. ### Overall assessment The PR replaces per-service PostgreSQL role/password boilerplate with a `services.postgresql.rolePasswords` submodule (modules/databases/postgresql-role-password.nix), migrates the six Vega role definitions (freshrss, paperless, radarr, sonarr, whisparr-v3) and modules/databases/immich.nix to it, and inlines the five role-less `ensureDatabases` entries (atticd, forgejo, metamcp_db, openwebui, postgres) into hosts/vega/databases/postgresql.nix. I verified in the checked-out tree that the deleted per-database files are no longer referenced from any host (only `./databases/postgresql.nix` is imported, hosts/vega/default.nix:58), that no consumer still refers to the old secret attribute names (`freshrss-db-password-postgres`, `radarr-db-password`, `immich-db-password-postgres`, etc. return no matches; the unrelated `freshrss-db-password`/`paperless-db-password`/`immich-db-password` names in modules/services/* are distinct attributes that already existed before the change), that the new module import paths resolve (hosts/vega/databases/postgresql.nix:9 `../../../modules/databases/postgresql-role-password.nix`, modules/databases/immich.nix `./postgresql-role-password.nix`), and that the generated database lists do not overlap the explicit list in postgresql.nix. No test fixture in tests/ references PostgreSQL, so no repository rule requires added coverage. One concrete, evidence-backed defect remains: the submodule's `ensureDBOwnership` option is consumed only by the oneshot SQL generator and is never propagated into the generated `services.postgresql.ensureUsers` entries, so the evaluated NixOS output no longer matches the pre-refactor `ensureUsers` shape for freshrss, paperless, and immich. ### Blocking findings None. ### Important findings None. ### Suggestions - **Submodule option `ensureDBOwnership` is not propagated to the NixOS `ensureUsers` field it is named after** (modules/databases/postgresql-role-password.nix:124; high confidence) The submodule declares `ensureDBOwnership` (line 68, default `true`, described as "Whether to grant ownership of specified databases to this role") and uses it only as a guard for the generated `ALTER DATABASE "<db>" OWNER TO "<role>";` SQL in the oneshot (line 142). The `services.postgresql.ensureUsers` generation (lines 117-125) emits only `name = roleCfg.role;` and `ensureClauses.login = roleCfg.login;` — it never sets the NixOS `ensureDBOwnership` field. The diff shows the pre-refactor definitions did set it: `hosts/vega/databases/freshrss.nix` and `hosts/vega/databases/paperless.nix` each had `ensureUsers = [ { name = <x>; ensureDBOwnership = true; } ];`, and `modules/databases/immich.nix` had `{ name = "immich"; ensureDBOwnership = true; ensureClauses.login = true; }`. Conversely, the generated entries now add `ensureClauses.login = true` for freshrss and paperless, which those files did not previously declare. Impact: The evaluated `services.postgresql.ensureUsers` output differs from the pre-refactor baseline for every migrated role: `ensureDBOwnership` is dropped and `ensureClauses.login = true` is added for freshrss and paperless. The end state is equivalent on a healthy boot because the oneshot (ordered `after`/`requires` `postgresql-setup.service`) now issues the `ALTER DATABASE ... OWNER TO ...` that NixOS previously issued during `postgresql-setup.service`, so this is not a demonstrated runtime regression. The concrete problem is the option contract: `ensureDBOwnership` shadows the NixOS field name but cannot control it, so the generated configuration is not the documented NixOS mechanism and a reader comparing this module against upstream `services.postgresql.ensureUsers` will be misled. Suggested fix: Either emit `ensureDBOwnership = roleCfg.ensureDBOwnership;` in the generated `ensureUsers` entry at line 124 so the option drives the NixOS field it is named after (and keep the oneshot `ALTER DATABASE` only when needed), or rename the submodule option (e.g. `alterDatabaseOwnership`) and state in its description that ownership is set by the generated oneshot rather than by `postgresql-setup.service`. Also make the `login` default explicit for freshrss/paperless if the added `ensureClauses.login = true` was not intended. ### Tests and validation - No configured deterministic checks. ### Questions - Was dropping `ensureDBOwnership = true` from the generated `ensureUsers` entries for freshrss, paperless, and immich deliberate (ownership delegated entirely to the oneshot), or should the submodule option also drive the NixOS field? - Is emitting `ensureClauses.login = true` for freshrss and paperless intended? Their pre-refactor `ensureUsers` entries declared only `ensureDBOwnership`, and the diff shows no `ensureClauses` for either. ### Review limitations - I did not run `nix flake check`, `just test`, or evaluate the configuration, so I cannot independently confirm the PR's claim that the evaluated `ensureDatabases`/`ensureUsers`/failure-monitor sets match the pre-refactor baseline; the `ensureUsers` comparison above is read directly from the supplied diff and module source. - I did not inspect the upstream nixpkgs `services.postgresql` module source, so the exact runtime semantics of `ensureUsers.ensureDBOwnership` and `ensureClauses.login`, and whether `services.postgresql` accepts a new `rolePasswords` sub-attribute in this pinned nixpkgs, are taken from the field names visible in the diff and from the PR's reported passing `nix flake check` rather than from supplied upstream source. - I did not verify that the SOPS keys exist for the new secret attribute names (`postgresql-role-password-<name>`) or that `.sops.yaml` recipients cover them; the `sopsFile`/`key` values are unchanged by the diff and I did not decrypt or inspect secret values. - I did not exercise the generated systemd units or any deployment; runtime ordering, idempotency, and heredoc quoting behaviour of the generated `psql ... <<SQL` script are not verified by me, and I report no defect in them. ### Diff coverage - `hosts/vega/databases/atticd.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/forgejo.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/freshrss.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/metamcp.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/openwebui.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/paperless.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/postgres.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/postgresql.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/radarr.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/sonarr.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/whisparr-v3.nix`: **reviewed** — included in a context-limited batch - `modules/databases/immich.nix`: **reviewed** — included in a context-limited batch - `modules/databases/postgresql-role-password.nix`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md - Commits considered: 2 - Previous automated review: none found - Findings: 1 </details>
fix(postgresql): propagate ensureDBOwnership to ensureUsers when role matches database
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 2m14s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 17m47s
0c2aa9d373
clankbot left a comment

Automated code review

Reviewed commit: 0c2aa9d3734abfc4171c16fd6ad4fb176c31a00a

Verdict: Ready to merge

No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory.

Overall assessment

Refactor of Vega's per-service PostgreSQL role-password boilerplate into a new submodule option, services.postgresql.rolePasswords.<name> (modules/databases/postgresql-role-password.nix), with freshrss, paperless, radarr, sonarr, whisparr-v3 (hosts/vega/databases/) and immich (modules/databases/immich.nix) migrated to the declarative form, and the five single-database stubs (atticd, forgejo, metamcp, openwebui, postgres) folded into a single ensureDatabases list in hosts/vega/databases/postgresql.nix. I checked the checked-out tree: all five folded database names are present in hosts/vega/databases/postgresql.nix:22 (atticd, forgejo, metamcp_db, openwebui, postgres), matching the deleted stub files in the diff; no file in the tree still imports the deleted stubs (grep databases/(atticd|forgejo|...) returns nothing) and no docs or tests reference them or the old unit/secret names (grep 'postgresql-set-' and grep 'db-password-postgres' match only the new module). The SOPS keys used by the migrated call sites still resolve (secrets/databases/{radarr,sonarr,whisparr-v3}.yaml each contain database.password; secrets/freshrss.yaml and secrets/paperless.yaml contain db-password). The module reproduces the previous generated output for the six call sites: owner/group/mode = "0400", the ALTER ROLE "<role>" WITH LOGIN PASSWORD clause, the ALTER DATABASE ... OWNER TO clauses for radarr/sonarr/whisparr-v3, the postgresql-set-<name>-password unit names, the postgresql-setup.service ordering, and the serviceFailureMonitor entries. The heredoc terminator SQL is emitted at column 0 after Nix indented-string de-indentation (minimum line indentation in the script string is 10 spaces, and the closing '' line is not counted), so it terminates for any number of SQL commands. serviceFailureMonitor consumes its services list via lib.genAttrs (modules/services/service-failure-monitor.nix:74), so duplicate entries are collapsed. No blocking defect found; one actionable observation about an option whose meaning differs between the two places the module uses it.

Blocking findings

None.

Important findings

None.

Suggestions

  • ensureDBOwnership means two different things in the two places the module consumes it (modules/databases/postgresql-role-password.nix:125; medium confidence)
    The submodule declares one ensureDBOwnership boolean (default true, documented as "Whether to grant ownership of specified databases to this role"), but the two consumers gate it differently: the services.postgresql.ensureUsers entry at line 125 uses roleCfg.ensureDBOwnership && (builtins.elem roleCfg.role roleCfg.databases), while the generated unit at line 143 uses only roleCfg.ensureDBOwnership && roleCfg.databases != [ ]. In the supplied call sites this is what keeps radarr/sonarr/whisparr-v3 at ensureDBOwnership = false in ensureUsers (their roles are radarr/sonarr/whisparr-v3 while hosts/vega/databases/radarr.nix declares databases = [ "radarr-log" "radarr-main" ]) and at true for freshrss/paperless/immich, which matches the pre-refactor ensureUsers blocks in the diff. The name-equality test is an implicit condition no caller states.
    Impact: Ownership for a role whose name does not literally appear in its own databases list is asserted only by the oneshot unit, never by postgresql-setup, while a role whose name does coincide gets it from both. A caller that sets ensureDBOwnership = true expecting postgresql-setup to claim ownership gets a different result depending on the role/database naming, and a future rename of a role or database silently moves ownership between the two mechanisms. No current Vega configuration is mis-evaluated, so this is not a defect in the supplied state.
    Suggested fix: Make the intent explicit: drive both consumers from the single ensureDBOwnership flag (the unit's ALTER DATABASE already covers the non-name-matching case), or split the option into two, e.g. setupDbOwnership for the ensureUsers entry and assignOwnership for the generated unit, so the caller states which behaviour it wants instead of relying on name equality.

Tests and validation

  • No configured deterministic checks.

Questions

  • The migrated freshrss and paperless files previously declared ensureUsers = [ { name = ...; ensureDBOwnership = true; } ] with no ensureClauses; the module now always emits ensureClauses.login = roleCfg.login with login defaulting to true (modules/databases/postgresql-role-password.nix:70 and :124), so postgresql-setup grants LOGIN to those two roles. The end state matches the old oneshot units, which ran ALTER ROLE <name> WITH LOGIN PASSWORD ..., but was the explicit LOGIN clause in ensureUsers intended for these two roles?
  • The generated SOPS secret attribute names change from freshrss-db-password-postgres, paperless-db-password-postgres, radarr-db-password, sonarr-db-password, whisparr-v3-db-password, immich-db-password-postgres to postgresql-role-password-<name>, which changes the installed secret file paths. grep over the checked-out tree finds no remaining reference to the old names, but I cannot see operator scripts, container bind mounts, or live host state outside the flake - can you confirm nothing external reads the old paths?
  • On Vega the new module is reachable twice: hosts/vega/databases/postgresql.nix:9 imports ../../../modules/databases/postgresql-role-password.nix and modules/databases/immich.nix:9 imports ./postgresql-role-password.nix, and hosts/vega/default.nix imports both (lines 57 and 58). Its config block is therefore instantiated twice, so services.postgresql.ensureDatabases and ensureUsers receive each entry twice and each generated unit's wantedBy/after/requires and each secret's restartUnits list is duplicated. I found no consumer that is order- or duplicate-sensitive (service-failure-monitor.nix uses lib.genAttrs; the backup script enumerates databases from psql rather than from ensureDatabases), but please confirm nix flake check and the evaluated services.postgresql.rolePasswords attrset (six entries) are as intended.
  • The generated unit now feeds SQL to psql through an unquoted <<SQL heredoc instead of --command=. Was that switch deliberate (e.g. to keep multi-command units readable in systemctl cat), given that an unquoted heredoc also subjects its body to shell parameter expansion, which is what the $password_sql interpolation relies on?

Review limitations

  • I did not run nix flake check, evaluate any host, or execute repository code; this review container has no Nix. The evaluated option values (the 14 ensureDatabases, the 6 ensureUsers, the serviceFailureMonitor entries, the generated unit scripts) are inferred by reading the module and call sites, not observed from an evaluation.
  • I read the checked-out head tree, so the pre-refactor state is known only from the supplied diff; I cannot diff the newly generated systemd unit scripts against the previously built ones.
  • I cannot inspect .sops.yaml key/recipient policy, secret file contents beyond the keys I grepped, or live host state, running units, and activation behaviour.
  • No test-coverage request is raised: no rule in the supplied AGENTS.md requires regression coverage for Nix module changes (it prescribes nix flake check as the validation gate for Nix module/configuration changes), and tests/ contains no PostgreSQL fixtures (grep postgresql in tests/ returns no matches).
  • I did not verify nixpkgs' own services.postgresql option types or its postgresql-setup script behaviour against a source; claims about ensureUsers/ensureClauses.login semantics are inferred from the diff's pre-refactor configuration, not from supplied nixpkgs source.

Diff coverage

  • hosts/vega/databases/atticd.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/forgejo.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/freshrss.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/metamcp.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/openwebui.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/paperless.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/postgres.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/postgresql.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/radarr.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/sonarr.nix: reviewed — included in a context-limited batch
  • hosts/vega/databases/whisparr-v3.nix: reviewed — included in a context-limited batch
  • modules/databases/immich.nix: reviewed — included in a context-limited batch
  • modules/databases/postgresql-role-password.nix: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 3
  • Previous automated review: none found
  • Findings: 1
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `0c2aa9d3734abfc4171c16fd6ad4fb176c31a00a` ## Verdict: Ready to merge No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory. ### Overall assessment Refactor of Vega's per-service PostgreSQL role-password boilerplate into a new submodule option, `services.postgresql.rolePasswords.<name>` (modules/databases/postgresql-role-password.nix), with freshrss, paperless, radarr, sonarr, whisparr-v3 (hosts/vega/databases/) and immich (modules/databases/immich.nix) migrated to the declarative form, and the five single-database stubs (atticd, forgejo, metamcp, openwebui, postgres) folded into a single `ensureDatabases` list in hosts/vega/databases/postgresql.nix. I checked the checked-out tree: all five folded database names are present in hosts/vega/databases/postgresql.nix:22 (`atticd`, `forgejo`, `metamcp_db`, `openwebui`, `postgres`), matching the deleted stub files in the diff; no file in the tree still imports the deleted stubs (`grep databases/(atticd|forgejo|...)` returns nothing) and no docs or tests reference them or the old unit/secret names (`grep 'postgresql-set-'` and `grep 'db-password-postgres'` match only the new module). The SOPS keys used by the migrated call sites still resolve (`secrets/databases/{radarr,sonarr,whisparr-v3}.yaml` each contain `database.password`; `secrets/freshrss.yaml` and `secrets/paperless.yaml` contain `db-password`). The module reproduces the previous generated output for the six call sites: `owner`/`group`/`mode = "0400"`, the `ALTER ROLE "<role>" WITH LOGIN PASSWORD` clause, the `ALTER DATABASE ... OWNER TO` clauses for radarr/sonarr/whisparr-v3, the `postgresql-set-<name>-password` unit names, the `postgresql-setup.service` ordering, and the `serviceFailureMonitor` entries. The heredoc terminator `SQL` is emitted at column 0 after Nix indented-string de-indentation (minimum line indentation in the `script` string is 10 spaces, and the closing `''` line is not counted), so it terminates for any number of SQL commands. `serviceFailureMonitor` consumes its `services` list via `lib.genAttrs` (modules/services/service-failure-monitor.nix:74), so duplicate entries are collapsed. No blocking defect found; one actionable observation about an option whose meaning differs between the two places the module uses it. ### Blocking findings None. ### Important findings None. ### Suggestions - **ensureDBOwnership means two different things in the two places the module consumes it** (modules/databases/postgresql-role-password.nix:125; medium confidence) The submodule declares one `ensureDBOwnership` boolean (default true, documented as "Whether to grant ownership of specified databases to this role"), but the two consumers gate it differently: the `services.postgresql.ensureUsers` entry at line 125 uses `roleCfg.ensureDBOwnership && (builtins.elem roleCfg.role roleCfg.databases)`, while the generated unit at line 143 uses only `roleCfg.ensureDBOwnership && roleCfg.databases != [ ]`. In the supplied call sites this is what keeps radarr/sonarr/whisparr-v3 at `ensureDBOwnership = false` in `ensureUsers` (their roles are `radarr`/`sonarr`/`whisparr-v3` while `hosts/vega/databases/radarr.nix` declares `databases = [ "radarr-log" "radarr-main" ]`) and at `true` for freshrss/paperless/immich, which matches the pre-refactor `ensureUsers` blocks in the diff. The name-equality test is an implicit condition no caller states. Impact: Ownership for a role whose name does not literally appear in its own `databases` list is asserted only by the oneshot unit, never by `postgresql-setup`, while a role whose name does coincide gets it from both. A caller that sets `ensureDBOwnership = true` expecting `postgresql-setup` to claim ownership gets a different result depending on the role/database naming, and a future rename of a role or database silently moves ownership between the two mechanisms. No current Vega configuration is mis-evaluated, so this is not a defect in the supplied state. Suggested fix: Make the intent explicit: drive both consumers from the single `ensureDBOwnership` flag (the unit's `ALTER DATABASE` already covers the non-name-matching case), or split the option into two, e.g. `setupDbOwnership` for the `ensureUsers` entry and `assignOwnership` for the generated unit, so the caller states which behaviour it wants instead of relying on name equality. ### Tests and validation - No configured deterministic checks. ### Questions - The migrated freshrss and paperless files previously declared `ensureUsers = [ { name = ...; ensureDBOwnership = true; } ]` with no `ensureClauses`; the module now always emits `ensureClauses.login = roleCfg.login` with `login` defaulting to true (modules/databases/postgresql-role-password.nix:70 and :124), so `postgresql-setup` grants LOGIN to those two roles. The end state matches the old oneshot units, which ran `ALTER ROLE <name> WITH LOGIN PASSWORD ...`, but was the explicit LOGIN clause in `ensureUsers` intended for these two roles? - The generated SOPS secret attribute names change from `freshrss-db-password-postgres`, `paperless-db-password-postgres`, `radarr-db-password`, `sonarr-db-password`, `whisparr-v3-db-password`, `immich-db-password-postgres` to `postgresql-role-password-<name>`, which changes the installed secret file paths. `grep` over the checked-out tree finds no remaining reference to the old names, but I cannot see operator scripts, container bind mounts, or live host state outside the flake - can you confirm nothing external reads the old paths? - On Vega the new module is reachable twice: hosts/vega/databases/postgresql.nix:9 imports `../../../modules/databases/postgresql-role-password.nix` and modules/databases/immich.nix:9 imports `./postgresql-role-password.nix`, and hosts/vega/default.nix imports both (lines 57 and 58). Its `config` block is therefore instantiated twice, so `services.postgresql.ensureDatabases` and `ensureUsers` receive each entry twice and each generated unit's `wantedBy`/`after`/`requires` and each secret's `restartUnits` list is duplicated. I found no consumer that is order- or duplicate-sensitive (service-failure-monitor.nix uses `lib.genAttrs`; the backup script enumerates databases from psql rather than from `ensureDatabases`), but please confirm `nix flake check` and the evaluated `services.postgresql.rolePasswords` attrset (six entries) are as intended. - The generated unit now feeds SQL to psql through an unquoted `<<SQL` heredoc instead of `--command=`. Was that switch deliberate (e.g. to keep multi-command units readable in `systemctl cat`), given that an unquoted heredoc also subjects its body to shell parameter expansion, which is what the `$password_sql` interpolation relies on? ### Review limitations - I did not run `nix flake check`, evaluate any host, or execute repository code; this review container has no Nix. The evaluated option values (the 14 `ensureDatabases`, the 6 `ensureUsers`, the `serviceFailureMonitor` entries, the generated unit scripts) are inferred by reading the module and call sites, not observed from an evaluation. - I read the checked-out head tree, so the pre-refactor state is known only from the supplied diff; I cannot diff the newly generated systemd unit scripts against the previously built ones. - I cannot inspect `.sops.yaml` key/recipient policy, secret file contents beyond the keys I grepped, or live host state, running units, and activation behaviour. - No test-coverage request is raised: no rule in the supplied AGENTS.md requires regression coverage for Nix module changes (it prescribes `nix flake check` as the validation gate for Nix module/configuration changes), and tests/ contains no PostgreSQL fixtures (`grep postgresql` in tests/ returns no matches). - I did not verify nixpkgs' own `services.postgresql` option types or its `postgresql-setup` script behaviour against a source; claims about `ensureUsers`/`ensureClauses.login` semantics are inferred from the diff's pre-refactor configuration, not from supplied nixpkgs source. ### Diff coverage - `hosts/vega/databases/atticd.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/forgejo.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/freshrss.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/metamcp.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/openwebui.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/paperless.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/postgres.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/postgresql.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/radarr.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/sonarr.nix`: **reviewed** — included in a context-limited batch - `hosts/vega/databases/whisparr-v3.nix`: **reviewed** — included in a context-limited batch - `modules/databases/immich.nix`: **reviewed** — included in a context-limited batch - `modules/databases/postgresql-role-password.nix`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md - Commits considered: 3 - Previous automated review: none found - Findings: 1 </details>
nimmo merged commit 684d22c81d into main 2026-10-08 15:48:08 +01:00
nimmo deleted branch feat/issue-274-consolidate-postgresql-boilerplate 2026-10-08 15:48:08 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/nixos-config!287
No description provided.