|
28 | 28 | configFile = pkgs.writeText "postgresql.conf" ( |
29 | 29 | lib.concatStringsSep "\n" ( |
30 | 30 | lib.mapAttrsToList (n: v: "${n} = ${toStr v}") ( |
31 | | - lib.filterAttrs (lib.const (x: x != null)) cfg.settings |
| 31 | + lib.filterAttrs (n: v: n != "includes" && v != null) cfg.settings |
32 | 32 | ) |
33 | 33 | ) |
| 34 | + + "\n" |
| 35 | + + lib.concatStringsSep "\n" (lib.map (f: "include '${f}'") cfg.settings.includes) |
34 | 36 | ); |
35 | 37 | pg_hba = pkgs.writeText "pg_hba.conf" ( |
36 | 38 | cfg.authentication + self.supabase.postgres.defaults.authentication |
|
55 | 57 | # primary_conninfo = 'host=localhost port=6543 user=replication' |
56 | 58 | ''; |
57 | 59 |
|
| 60 | + supautils-conf = ./supautils.conf; |
58 | 61 | in |
59 | 62 | { |
60 | 63 | options = { |
|
85 | 88 | List of libraries to be preloaded. |
86 | 89 | ''; |
87 | 90 | }; |
| 91 | + |
| 92 | + includes = lib.mkOption { |
| 93 | + type = listOf str; |
| 94 | + default = [ |
| 95 | + "/etc/postgresql-custom/read-replica.conf" |
| 96 | + "/etc/postgresql-custom/supautils.conf" |
| 97 | + ]; |
| 98 | + description = '' |
| 99 | + List of additional postgresql.conf files to be included. |
| 100 | + ''; |
| 101 | + }; |
88 | 102 | }; |
89 | 103 | }; |
90 | 104 | default = { }; |
|
144 | 158 |
|
145 | 159 | superUser = lib.mkOption { |
146 | 160 | type = lib.types.str; |
147 | | - default = "postgres"; |
| 161 | + default = "supabase_admin"; |
148 | 162 | internal = true; |
149 | 163 | readOnly = true; |
150 | 164 | description = '' |
|
183 | 197 | uid = config.ids.uids.postgres; |
184 | 198 | group = "postgres"; |
185 | 199 | home = "${cfg.dataDir}"; |
186 | | - useDefaultShell = true; |
| 200 | + shell = "/usr/bin/bash"; |
187 | 201 | }; |
188 | 202 |
|
189 | 203 | systemd.tmpfiles.rules = [ |
|
200 | 214 | "L+ /usr/lib/postgresql/bin - - - - ${cfg.package}/bin" |
201 | 215 | "L+ /usr/lib/postgresql/share - - - - ${cfg.package}/share" |
202 | 216 | "L+ /usr/lib/postgresql/lib - - - - ${cfg.package}/lib" |
| 217 | + "L+ /etc/postgresql-custom/extension-custom-scripts - - - - ${./extension-custom-scripts}" |
203 | 218 |
|
204 | 219 | # Copy configuration files |
205 | 220 | "C /etc/postgresql/pg_hba.conf 0440 ${defaultUser} ${defaultGroup} - ${pg_hba}" |
206 | 221 | "C /etc/postgresql/pg_ident.conf 0440 ${defaultUser} ${defaultGroup} - ${pg_ident}" |
207 | 222 | "C /etc/postgresql/postgresql.conf 0440 ${defaultUser} ${defaultGroup} - ${configFile}" |
208 | 223 | "C /etc/postgresql-custom/read-replica.conf 0664 ${defaultUser} ${defaultGroup} - ${read-replica-conf}" |
| 224 | + "C /etc/postgresql-custom/supautils.conf 0664 ${defaultUser} ${defaultGroup} - ${supautils-conf}" |
209 | 225 | ]; |
210 | 226 |
|
211 | 227 | environment = { |
|
240 | 256 | "plpgsql" |
241 | 257 | "plpgsql_check" |
242 | 258 | "supabase_vault" |
| 259 | + "supautils" |
243 | 260 | ]; |
244 | 261 | } |
245 | 262 | (lib.mkIf ((lib.toInt (lib.versions.major cfg.package.version)) < 16) { |
|
368 | 385 | serviceConfig = { |
369 | 386 | Type = "oneshot"; |
370 | 387 | RemainAfterExit = true; |
371 | | - ExecStart = lib.getExe (pkgs.writeShellScriptBin "setup-locales" '' |
372 | | - PATH=/usr/sbin:/usr/bin |
373 | | - /usr/sbin/locale-gen |
374 | | - /usr/sbin/update-locale |
375 | | - ''); |
| 388 | + ExecStart = lib.getExe ( |
| 389 | + pkgs.writeShellScriptBin "setup-locales" '' |
| 390 | + PATH=/usr/sbin:/usr/bin |
| 391 | + /usr/sbin/locale-gen |
| 392 | + /usr/sbin/update-locale |
| 393 | + '' |
| 394 | + ); |
376 | 395 | }; |
377 | 396 | }; |
378 | 397 | }; |
|
0 commit comments