Skip to content

Commit ddd9802

Browse files
committed
feat: configure supautils extension
1 parent 6f01e90 commit ddd9802

File tree

17 files changed

+52
-96
lines changed

17 files changed

+52
-96
lines changed

ansible/tasks/setup-docker.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

ansible/tasks/setup-postgres.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
- 'custom-overrides.conf'
1111
when: debpkg_mode or nixpkg_mode
1212

13-
# Install extensions before init
14-
- name: Install Postgres extensions
15-
import_tasks: tasks/setup-docker.yml
16-
when: debpkg_mode or stage2_nix
17-
1813
#stage 2 postgres tasks
1914
- name: stage2 postgres tasks
2015
import_tasks: tasks/stage2-setup-postgres.yml

nix/config.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ let
2626
default_text_search_config = "pg_catalog.english";
2727
effective_cache_size = "128MB";
2828
extra_float_digits = "0";
29-
include = "/etc/postgresql-custom/read-replica.conf";
3029
ident_file = "/etc/postgresql/pg_ident.conf";
3130
jit = "off";
3231
jit_provider = "llvmjit";

nix/systemModules/postgres/default.nix

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ let
2828
configFile = pkgs.writeText "postgresql.conf" (
2929
lib.concatStringsSep "\n" (
3030
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
3232
)
3333
)
34+
+ "\n"
35+
+ lib.concatStringsSep "\n" (lib.map (f: "include '${f}'") cfg.settings.includes)
3436
);
3537
pg_hba = pkgs.writeText "pg_hba.conf" (
3638
cfg.authentication + self.supabase.postgres.defaults.authentication
@@ -55,6 +57,7 @@ let
5557
# primary_conninfo = 'host=localhost port=6543 user=replication'
5658
'';
5759

60+
supautils-conf = ./supautils.conf;
5861
in
5962
{
6063
options = {
@@ -85,6 +88,17 @@ in
8588
List of libraries to be preloaded.
8689
'';
8790
};
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+
};
88102
};
89103
};
90104
default = { };
@@ -144,7 +158,7 @@ in
144158

145159
superUser = lib.mkOption {
146160
type = lib.types.str;
147-
default = "postgres";
161+
default = "supabase_admin";
148162
internal = true;
149163
readOnly = true;
150164
description = ''
@@ -183,7 +197,7 @@ in
183197
uid = config.ids.uids.postgres;
184198
group = "postgres";
185199
home = "${cfg.dataDir}";
186-
useDefaultShell = true;
200+
shell = "/usr/bin/bash";
187201
};
188202

189203
systemd.tmpfiles.rules = [
@@ -200,12 +214,14 @@ in
200214
"L+ /usr/lib/postgresql/bin - - - - ${cfg.package}/bin"
201215
"L+ /usr/lib/postgresql/share - - - - ${cfg.package}/share"
202216
"L+ /usr/lib/postgresql/lib - - - - ${cfg.package}/lib"
217+
"L+ /etc/postgresql-custom/extension-custom-scripts - - - - ${./extension-custom-scripts}"
203218

204219
# Copy configuration files
205220
"C /etc/postgresql/pg_hba.conf 0440 ${defaultUser} ${defaultGroup} - ${pg_hba}"
206221
"C /etc/postgresql/pg_ident.conf 0440 ${defaultUser} ${defaultGroup} - ${pg_ident}"
207222
"C /etc/postgresql/postgresql.conf 0440 ${defaultUser} ${defaultGroup} - ${configFile}"
208223
"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}"
209225
];
210226

211227
environment = {
@@ -240,6 +256,7 @@ in
240256
"plpgsql"
241257
"plpgsql_check"
242258
"supabase_vault"
259+
"supautils"
243260
];
244261
}
245262
(lib.mkIf ((lib.toInt (lib.versions.major cfg.package.version)) < 16) {
@@ -368,11 +385,13 @@ in
368385
serviceConfig = {
369386
Type = "oneshot";
370387
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+
);
376395
};
377396
};
378397
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)