2.1 KiB
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:
- Enabling TCP/IP login and also accepting password authentication from localhost with
shb.postgresql.enableTCPIP. - Enhance the
ensure*upstream option by setting up a database's password from a password file withshb.postgresql.ensures. - Debug logging with
auto_explainandpg_stat_statementswithshb.postgresql.debug.
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@