Skip to content

Replace HYDRA_DBI with HYDRA_DATABASE_URL everywhere - #1851

Merged
Ericson2314 merged 1 commit into
NixOS:masterfrom
obsidiansystems:single-db-url
Aug 4, 2026
Merged

Replace HYDRA_DBI with HYDRA_DATABASE_URL everywhere#1851
Ericson2314 merged 1 commit into
NixOS:masterfrom
obsidiansystems:single-db-url

Conversation

@Ericson2314

Copy link
Copy Markdown
Member

Hydra grew a second database-connection convention when the Rust queue runner arrived: it takes a standard postgres:// URL (db_url / HYDRA_DATABASE_URL), while the Perl and C++ services read HYDRA_DBI, a Perl DBI string. Converge on the URL as the single convention before more Rust services appear, rather than teaching each of them the legacy DBI syntax.

The two formats are equally expressive — the PostgreSQL URI scheme accepts every libpq keyword as a query parameter — so nothing is lost, and each consumer needs only a small change:

  • Perl: Hydra::Model::DB converts the URL to a DBI DSN with URI::db (new dependency). See the comment there for the user/password caveat.

  • C++ (hydra-evaluator): libpq accepts a postgres:// URL verbatim, so the DBI-to-conninfo translation code is deleted outright.

  • NixOS module: the dbi option is replaced by dbUrl, and all services now get HYDRA_DATABASE_URL with a per-service application_name query parameter. Neither hydra.nixos.org nor staging ever set dbi, so the option's removal breaks no known deployment.

  • The foreman dev scripts, test harness, and manual switch accordingly. The test harness already exported both variables; the HYDRA_DBI half is now dropped.

The Perl and C++ in-code default becomes postgres:///hydra, which is byte-for-byte equivalent to the old dbi:Pg:dbname=hydra; (local socket, OS-user auth). The NixOS module default matches the queue runner's explicit postgres://hydra@%2Frun%2Fpostgresql:5432/hydra.

Hydra grew a second database-connection convention when the Rust queue
runner arrived: it takes a standard `postgres://` URL (`db_url` /
`HYDRA_DATABASE_URL`), while the Perl and C++ services read `HYDRA_DBI`,
a Perl DBI string. Converge on the URL as the single convention before
more Rust services appear, rather than teaching each of them the legacy
DBI syntax.

The two formats are equally expressive — the PostgreSQL URI scheme
accepts every libpq keyword as a query parameter — so nothing is lost,
and each consumer needs only a small change:

- Perl: `Hydra::Model::DB` converts the URL to a DBI DSN with `URI::db`
  (new dependency). See the comment there for the user/password caveat.

- C++ (`hydra-evaluator`): libpq accepts a `postgres://` URL verbatim,
  so the DBI-to-conninfo translation code is deleted outright.

- NixOS module: the `dbi` option is replaced by `dbUrl`, and all
  services now get `HYDRA_DATABASE_URL` with a per-service
  `application_name` query parameter. Neither hydra.nixos.org nor
  staging ever set `dbi`, so the option's removal breaks no known
  deployment.

- The foreman dev scripts, test harness, and manual switch accordingly.
  The test harness already exported both variables; the `HYDRA_DBI` half
  is now dropped.

The Perl and C++ in-code default becomes `postgres:///hydra`, which is
byte-for-byte equivalent to the old `dbi:Pg:dbname=hydra;` (local
socket, OS-user auth). The NixOS module default matches the queue
runner's explicit `postgres://hydra@%2Frun%2Fpostgresql:5432/hydra`.
@Ericson2314
Ericson2314 added this pull request to the merge queue Aug 4, 2026
Merged via the queue into NixOS:master with commit 65da21b Aug 4, 2026
2 checks passed
@Ericson2314
Ericson2314 deleted the single-db-url branch August 4, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants