Consolidate PostgreSQL database and role-password boilerplate on Vega #274

Closed
opened 2026-10-06 20:08:24 +01:00 by nimmo · 1 comment
Owner

Context & Problem

In hosts/vega/databases/:

  • paperless.nix
  • radarr.nix
  • sonarr.nix
  • whisparr-v3.nix
  • freshrss.nix
  • modules/databases/immich.nix

All repeat almost identical ~50-line oneshot systemd services (postgresql-set-<service>-password) executing ALTER ROLE <name> WITH LOGIN PASSWORD '$password' using SOPS secret paths.
Additionally, single-database definitions (atticd.nix, forgejo.nix, metamcp.nix, openwebui.nix, postgres.nix) exist as tiny 3-line files doing nothing other than services.postgresql.ensureDatabases = [ "<name>" ];.

Scope

  • hosts/vega/databases/
  • modules/databases/immich.nix
  • Potential reusable module: modules/databases/postgresql-role-password.nix (or an option in postgresql.nix)

Implementation Checklist

  • Create a parameterized helper or module option (e.g. services.postgresql.rolePasswords.<name> = { sopsFile = ...; key = ...; databases = [ ... ]; };) that generates the required SOPS secret and oneshot password configuration service.
  • Migrate paperless.nix, radarr.nix, sonarr.nix, whisparr-v3.nix, freshrss.nix, and immich.nix to use this declarative abstraction.
  • Consolidate standalone trivial ensureDatabases files into a single coherent list in hosts/vega/databases/postgresql.nix.
  • Verify database roles and passwords remain correctly set on Vega.

Completion Criteria

  • Eliminated ~200 lines of repetitive oneshot shell scripts.
  • Vega database configuration evaluates cleanly and nix flake check passes.
## Context & Problem In `hosts/vega/databases/`: - `paperless.nix` - `radarr.nix` - `sonarr.nix` - `whisparr-v3.nix` - `freshrss.nix` - `modules/databases/immich.nix` All repeat almost identical ~50-line oneshot systemd services (`postgresql-set-<service>-password`) executing `ALTER ROLE <name> WITH LOGIN PASSWORD '$password'` using SOPS secret paths. Additionally, single-database definitions (`atticd.nix`, `forgejo.nix`, `metamcp.nix`, `openwebui.nix`, `postgres.nix`) exist as tiny 3-line files doing nothing other than `services.postgresql.ensureDatabases = [ "<name>" ];`. ## Scope - `hosts/vega/databases/` - `modules/databases/immich.nix` - Potential reusable module: `modules/databases/postgresql-role-password.nix` (or an option in `postgresql.nix`) ## Implementation Checklist - [ ] Create a parameterized helper or module option (e.g. `services.postgresql.rolePasswords.<name> = { sopsFile = ...; key = ...; databases = [ ... ]; };`) that generates the required SOPS secret and oneshot password configuration service. - [ ] Migrate `paperless.nix`, `radarr.nix`, `sonarr.nix`, `whisparr-v3.nix`, `freshrss.nix`, and `immich.nix` to use this declarative abstraction. - [ ] Consolidate standalone trivial `ensureDatabases` files into a single coherent list in `hosts/vega/databases/postgresql.nix`. - [ ] Verify database roles and passwords remain correctly set on Vega. ## Completion Criteria - Eliminated ~200 lines of repetitive oneshot shell scripts. - Vega database configuration evaluates cleanly and `nix flake check` passes.
Author
Owner

Completed in PR #287.

  • Created reusable modules/databases/postgresql-role-password.nix providing declarative services.postgresql.rolePasswords.<name>.
  • Consolidated repetitive oneshot systemd units, SOPS secret specifications, and failure monitoring across freshrss, paperless, radarr, sonarr, whisparr-v3, and immich.
  • Consolidated 5 single-database stub files (atticd, forgejo, metamcp, openwebui, postgres) into hosts/vega/databases/postgresql.nix.
  • Flake checks passed and automated review completed with verdict "Ready to merge". Merged to main in commit 684d22c.
Completed in PR #287. - Created reusable `modules/databases/postgresql-role-password.nix` providing declarative `services.postgresql.rolePasswords.<name>`. - Consolidated repetitive oneshot systemd units, SOPS secret specifications, and failure monitoring across `freshrss`, `paperless`, `radarr`, `sonarr`, `whisparr-v3`, and `immich`. - Consolidated 5 single-database stub files (`atticd`, `forgejo`, `metamcp`, `openwebui`, `postgres`) into `hosts/vega/databases/postgresql.nix`. - Flake checks passed and automated review completed with verdict "Ready to merge". Merged to `main` in commit `684d22c`.
nimmo closed this issue 2026-10-08 15:48:27 +01:00
Sign in to join this conversation.
No assignees
1 participant
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#274
No description provided.