From a723672c20f951888ce1d7049ed6b989b0b953e6 Mon Sep 17 00:00:00 2001 From: danbst Date: Mon, 16 Mar 2020 19:18:23 +0200 Subject: doc/postgresql: apply xmlformat --- nixos/modules/services/databases/postgresql.xml | 78 +++++++++++++------------ 1 file changed, 42 insertions(+), 36 deletions(-) (limited to 'nixos/modules/services/databases') diff --git a/nixos/modules/services/databases/postgresql.xml b/nixos/modules/services/databases/postgresql.xml index 1754f19fe1eb..07af4c937f03 100644 --- a/nixos/modules/services/databases/postgresql.xml +++ b/nixos/modules/services/databases/postgresql.xml @@ -7,12 +7,10 @@ - Source: - modules/services/databases/postgresql.nix + Source: modules/services/databases/postgresql.nix - Upstream documentation: - + Upstream documentation: @@ -23,18 +21,12 @@ Configuring - To enable PostgreSQL, add the following to your - configuration.nix: + To enable PostgreSQL, add the following to your configuration.nix: = true; = pkgs.postgresql_11; - Note that you are required to specify the desired version of PostgreSQL - (e.g. pkgs.postgresql_11). Since upgrading your - PostgreSQL version requires a database dump and reload (see below), NixOS - cannot provide a default value for - such as the most recent - release of PostgreSQL. + Note that you are required to specify the desired version of PostgreSQL (e.g. pkgs.postgresql_11). Since upgrading your PostgreSQL version requires a database dump and reload (see below), NixOS cannot provide a default value for such as the most recent release of PostgreSQL. - By default, PostgreSQL stores its databases in - /var/lib/postgresql/$psqlSchema. You can override this using - , e.g. + By default, PostgreSQL stores its databases in /var/lib/postgresql/$psqlSchema. You can override this using , e.g. = "/data/postgresql"; @@ -64,7 +54,6 @@ Type "help" for help. Major PostgreSQL upgrade requires PostgreSQL downtime and a few imperative steps to be called. To simplify this process, use the following NixOS module: - containers.temp-pg.config.services.postgresql = { enable = true; @@ -95,36 +84,52 @@ Type "help" for help. '') ]; - + + - The upgrade process is: + The upgrade process is: + - Rebuild nixos configuration with the configuration above added to your configuration.nix. Alternatively, add that into separate file and reference it in imports list. - Login as root (sudo su -) - Run upgrade-pg-cluster. It will stop old postgresql, initialize new one and migrate old one to new one. You may supply arguments like --jobs 4 and --link to speedup migration process. See for details. - Change postgresql package in NixOS configuration to the one you were upgrading to, and change dataDir to the one you have migrated to. Rebuild NixOS. This should start new postgres using upgraded data directory. - After upgrade you may want to ANALYZE new db. + + + Rebuild nixos configuration with the configuration above added to your configuration.nix. Alternatively, add that into separate file and reference it in imports list. + + + + + Login as root (sudo su -) + + + + + Run upgrade-pg-cluster. It will stop old postgresql, initialize new one and migrate old one to new one. You may supply arguments like --jobs 4 and --link to speedup migration process. See for details. + + + + + Change postgresql package in NixOS configuration to the one you were upgrading to, and change dataDir to the one you have migrated to. Rebuild NixOS. This should start new postgres using upgraded data directory. + + + + + After upgrade you may want to ANALYZE new db. + + - -
Options - A complete list of options for the PostgreSQL module may be found - here. + A complete list of options for the PostgreSQL module may be found here.
Plugins - Plugins collection for each PostgreSQL version can be accessed with - .pkgs. For example, for - pkgs.postgresql_11 package, its plugin collection is - accessed by pkgs.postgresql_11.pkgs: + Plugins collection for each PostgreSQL version can be accessed with .pkgs. For example, for pkgs.postgresql_11 package, its plugin collection is accessed by pkgs.postgresql_11.pkgs: $ nix repl '<nixpkgs>' @@ -141,8 +146,9 @@ postgresql_11.pkgs.pg_partman postgresql_11.pkgs.pgroonga ... + - To add plugins via NixOS configuration, set services.postgresql.extraPlugins: + To add plugins via NixOS configuration, set services.postgresql.extraPlugins: = pkgs.postgresql_11; = with pkgs.postgresql_11.pkgs; [ @@ -151,10 +157,9 @@ postgresql_11.pkgs.pg_partman postgresql_11.pkgs.pgroonga ]; + - You can build custom PostgreSQL-with-plugins (to be used outside of NixOS) using - function .withPackages. For example, creating a custom - PostgreSQL package in an overlay can look like: + You can build custom PostgreSQL-with-plugins (to be used outside of NixOS) using function .withPackages. For example, creating a custom PostgreSQL package in an overlay can look like: self: super: { postgresql_custom = self.postgresql_11.withPackages (ps: [ @@ -164,8 +169,9 @@ self: super: { } + - Here's a recipe on how to override a particular plugin through an overlay: + Here's a recipe on how to override a particular plugin through an overlay: self: super: { postgresql_11 = super.postgresql_11.override { this = self.postgresql_11; } // { -- cgit 1.4.1