selfhostblocks/modules/blocks/postgresql/docs/default.md
2025-12-29 23:26:30 +01:00

2.1 KiB

PostgreSQL Block

Defined in /modules/blocks/postgresql.nix.

This block sets up a PostgreSQL database.

Compared to the upstream nixpkgs module, this module also sets up:

Usage

Ensure User and Database

Ensure a database and user exists:

shb.postgresql.ensures = [
  {
    username = "firefly-iii";
    database = "firefly-iii";
  }
];

Also set up the database password from a file path:

shb.postgresql.ensures = [
  {
    username = "firefly-iii";
    database = "firefly-iii";
    passwordFile = "/run/secrets/firefly-iii_db_password";
  }
];

Database Backup Requester Contracts

This block can be backed up using the database backup contract.

Contract integration tests are defined in /test/contracts/databasebackup.nix.

Backing up All Databases

{
  my.backup.provider."postgresql" = {
    request = config.shb.postgresql.databasebackup;

    settings = {
      // Specific options for the backup provider.
    };
  };
}

Tests

Specific integration tests are defined in /test/blocks/postgresql.nix.

Options Reference

id-prefix: blocks-postgresql-options-
list-id: selfhostblocks-block-postgresql-options
source: @OPTIONS_JSON@