Postgres
Options
services.postgres.enable
Whether to enable Add PostgreSQL process. .
Type: boolean
Default:
false
Example:
true
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.package
The PostgreSQL package to use. Use this to override the default with a specific version.
Type: package
Default:
pkgs.postgresql
Example:
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.createDatabase
Create a database named like current user on startup. Only applies when initialDatabases is an empty list.
Type: boolean
Default:
true
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.extensions
Additional PostgreSQL extensions to install.
The available extensions are:
- age
- anonymizer
- apache_datasketches
- citus
- cstore_fdw
- h3-pg
- hypopg
- ip4r
- jsonb_deep_sum
- lantern
- omnigres
- periods
- pg-gvm
- pg-semver
- pg_auto_failover
- pg_bigm
- pg_byteamagic
- pg_cron
- pg_csv
- pg_ed25519
- pg_embedding
- pg_graphql
- pg_hint_plan
- pg_hll
- pg_ivm
- pg_libversion
- pg_net
- pg_partman
- pg_rational
- pg_relusage
- pg_repack
- pg_roaringbitmap
- pg_safeupdate
- pg_similarity
- pg_squeeze
- pg_tle
- pg_topn
- pg_uuidv7
- pgaudit
- pgddl
- pgjwt
- pgmq
- pgroonga
- pgrouting
- pgsodium
- pgsql-http
- pgtap
- pgvecto-rs
- pgvector
- pgvectorscale
- pgx_ulid
- plperl
- plpgsql_check
- plpython3
- plr
- pltcl
- plv8
- postgis
- repmgr
- rum
- smlar
- sqlite_fdw
- system_stats
- tds_fdw
- temporal_tables
- timescaledb
- timescaledb-apache
- timescaledb_toolkit
- tsja
- vectorchord
- wal2json
Type: null or (function that evaluates to a(n) list of package)
Default:
null
Example:
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.hbaConf
The contents of a custom pg_hba.conf file to copy into the postgres installation. This allows for custom connection rules that you want to establish on the server.
Type: null or string
Default:
null
Example:
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.initdbArgs
Additional arguments passed to initdb during data dir
initialisation.
Type: list of strings concatenated with “\n”
Default:
Example:
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.initialDatabases
List of database names and their initial schemas that should be used to create databases on the first startup of Postgres. The schema attribute is optional: If not specified, an empty database is created.
Type: list of (submodule)
Default:
[ ]
Example:
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.initialDatabases.*.initialSQL
SQL commands to run on this specific database during it’s initialization. Multiple SQL expressions can be separated by semicolons.
Type: null or string
Default:
null
Example:
CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);
INSERT INTO users (name) VALUES ('admin');
CREATE EXTENSION IF NOT EXISTS pg_uuidv7;
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.initialDatabases.*.name
The name of the database to create.
Type: string
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.initialDatabases.*.pass
Password of owner of the database (only takes effect if user is not null).
Type: null or string
Default:
null
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.initialDatabases.*.schema
The initial schema of the database; if null (the default), an empty database is created.
Type: null or absolute path
Default:
null
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.initialDatabases.*.user
Username of owner of the database (if null, the default $USER is used).
Type: null or string
Default:
null
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.initialScript
Initial SQL commands to run during database initialization. This can be multiple
SQL expressions separated by a semi-colon.
Use initialScript for server-wide setup, such as creating roles or configuring
global settings. For database-specific initialization, use initialSQL within
initialDatabases.
Type: null or string
Default:
null
Example:
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.listen_addresses
A comma-separated list of TCP/IP address(es) on which the server should listen for connections.
By default, the server only accepts connections over unix sockets.
This option is parsed to set the PGHOST environment variable.
Special values:
- '*' to listen on all available network interfaces.
- '0.0.0.0' to listen on all available IPv4 network interfaces.
- '::' to listen on all available IPv6 network interfaces.
- 'localhost' to listen only on the loopback interface.
- '' (empty string) disables TCP/IP connections and listens only on the unix socket.
Type: string
Default:
""
Example:
"127.0.0.1"
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.port
The TCP port to accept connections.
Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)
Default:
5432
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix
services.postgres.settings
PostgreSQL configuration. Refer to
https://www.postgresql.org/docs/11/config-setting.html#CONFIG-SETTING-CONFIGURATION-FILE
for an overview of postgresql.conf.
String values will automatically be enclosed in single quotes. Single quotes will be escaped with two single quotes as described by the upstream documentation linked above.
Type: attribute set of (boolean or floating point number or signed integer or string)
Default:
{ }
Example:
{
log_connections = true;
log_statement = "all";
logging_collector = true
log_disconnections = true
log_destination = lib.mkForce "syslog";
}
Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/postgres.nix