@@ -27,10 +27,10 @@
2727 <filename>configuration.nix</filename>:
2828<programlisting>
2929<xref linkend="opt-services.postgresql.enable"/> = true;
30−<xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql_9_4;
30+<xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql_11;
3131</programlisting>
3232 Note that you are required to specify the desired version of PostgreSQL
33− (e.g. <literal>pkgs.postgresql_9_4</literal>). Since upgrading your
33+ (e.g. <literal>pkgs.postgresql_11</literal>). Since upgrading your
3434 PostgreSQL version requires a database dump and reload (see below), NixOS
3535 cannot provide a default value for
3636 <xref linkend="opt-services.postgresql.package"/> such as the most recent
@@ -74,4 +74,70 @@ Type "help" for help.
7474 <link linkend="opt-services.postgresql.enable">here</link>.
7575 </para>
7676 </section>
77+ <section xml:id="module-services-postgres-plugins">
78+ <title>Plugins</title>
79+
80+ <para>
81+ Plugins collection for each PostgreSQL version can be accessed with
82+ <literal>.pkgs</literal>. For example, for
83+ <literal>pkgs.postgresql_11</literal> package, its plugin collection is
84+ accessed by <literal>pkgs.postgresql_11.pkgs</literal>:
85+<screen>
86+<prompt>$ </prompt>nix repl '<nixpkgs>'
87+
88+Loading '<nixpkgs>'...
89+Added 10574 variables.
90+
91+<prompt>nix-repl> </prompt>postgresql_11.pkgs.<TAB><TAB>
92+postgresql_11.pkgs.cstore_fdw postgresql_11.pkgs.pg_repack
93+postgresql_11.pkgs.pg_auto_failover postgresql_11.pkgs.pg_safeupdate
94+postgresql_11.pkgs.pg_bigm postgresql_11.pkgs.pg_similarity
95+postgresql_11.pkgs.pg_cron postgresql_11.pkgs.pg_topn
96+postgresql_11.pkgs.pg_hll postgresql_11.pkgs.pgjwt
97+postgresql_11.pkgs.pg_partman postgresql_11.pkgs.pgroonga
98+...
99+</screen>
100+ </para>
101+ <para>
102+ To add plugins via NixOS configuration, set <literal>services.postgresql.extraPlugins</literal>:
103+<programlisting>
104+<xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql_11;
105+<xref linkend="opt-services.postgresql.extraPlugins"/> = with pkgs.postgresql_11.pkgs; [
106+ pg_repack
107+ postgis
108+];
109+</programlisting>
110+ </para>
111+ <para>
112+ You can build custom PostgreSQL-with-plugins (to be used outside of NixOS) using
113+ function <literal>.withPackages</literal>. For example, creating a custom
114+ PostgreSQL package in an overlay can look like:
115+<programlisting>
116+self: super: {
117+ postgresql_custom = self.postgresql_11.withPackages (ps: [
118+ ps.pg_repack
119+ ps.postgis
120+ ]);
121+}
122+</programlisting>
123+ </para>
124+ <para>
125+ Here's a recipe on how to override a particular plugin through an overlay:
126+<programlisting>
127+self: super: {
128+ postgresql_11 = super.postgresql_11.override { this = self.postgresql_11; } // {
129+ pkgs = super.postgresql_11.pkgs // {
130+ pg_repack = super.postgresql_11.pkgs.pg_repack.overrideAttrs (_: {
131+ name = "pg_repack-v20181024";
132+ src = self.fetchzip {
133+ url = "https://github.com/reorg/pg_repack/archive/923fa2f3c709a506e111cc963034bf2fd127aa00.tar.gz";
134+ sha256 = "17k6hq9xaax87yz79j773qyigm4fwk8z4zh5cyp6z0sxnwfqxxw5";
135+ };
136+ });
137+ };
138+ };
139+}
140+</programlisting>
141+ </para>
142+ </section>
77143</chapter>