Skip to content

Commit 7f47802

Browse files
committed
chore: postgres 15 doesnt support include directive
1 parent ad4af3c commit 7f47802

File tree

1 file changed

+42
-16
lines changed

1 file changed

+42
-16
lines changed

nix/packages/lib.nix

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,33 @@
4848
name = "readreplica.conf";
4949
path = ../../ansible/files/postgresql_config/custom_read_replica.conf.j2;
5050
};
51-
pgHbaConfigFile = builtins.path {
52-
name = "pg_hba.conf";
53-
path = ../../ansible/files/postgresql_config/pg_hba.conf.j2;
54-
};
55-
pgHbaUsersPublicConfigFile = builtins.path {
56-
name = "pg_hba_users_public.conf";
57-
path = ../../ansible/files/postgresql_config/pg_hba_users_public.conf.j2;
58-
};
59-
pgHbaPublicConfigFile = builtins.path {
60-
name = "pg_hba_public.conf";
61-
path = ../../ansible/files/postgresql_config/pg_hba_public.conf.j2;
62-
};
51+
pgHbaConfigFile =
52+
if pkgs == psql_15 then
53+
builtins.path {
54+
name = "pg_hba.conf";
55+
path = ../../ansible/files/postgresql_config/pg_hba.conf_15.j2;
56+
}
57+
else
58+
builtins.path {
59+
name = "pg_hba.conf";
60+
path = ../../ansible/files/postgresql_config/pg_hba.conf.j2;
61+
};
62+
pgHbaUsersPublicConfigFile =
63+
if pkgs != psql_15 then
64+
builtins.path {
65+
name = "pg_hba_users_public.conf";
66+
path = ../../ansible/files/postgresql_config/pg_hba_users_public.conf.j2;
67+
}
68+
else
69+
null;
70+
pgHbaPublicConfigFile =
71+
if pkgs != psql_15 then
72+
builtins.path {
73+
name = "pg_hba_public.conf";
74+
path = ../../ansible/files/postgresql_config/pg_hba_public.conf.j2;
75+
}
76+
else
77+
null;
6378
pgIdentConfigFile = builtins.path {
6479
name = "pg_ident.conf";
6580
path = ../../ansible/files/postgresql_config/pg_ident.conf.j2;
@@ -123,8 +138,14 @@
123138
cp ${paths.loggingConfigFile} $out/etc/postgresql-custom/logging.conf || { echo "Failed to copy logging.conf"; exit 1; }
124139
cp ${paths.readReplicaConfigFile} $out/etc/postgresql-custom/read-replica.conf || { echo "Failed to copy read-replica.conf"; exit 1; }
125140
cp ${paths.pgHbaConfigFile} $out/etc/postgresql/pg_hba.conf || { echo "Failed to copy pg_hba.conf"; exit 1; }
126-
cp ${paths.pgHbaUsersPublicConfigFile} $out/etc/postgresql/pg_hba_users_public.conf || { echo "Failed to copy pg_hba_users_public.conf"; exit 1; }
127-
cp ${paths.pgHbaPublicConfigFile} $out/etc/postgresql/pg_hba_public.conf || { echo "Failed to copy pg_hba_public.conf"; exit 1; }
141+
142+
# these shouldn't exist on psql_15
143+
if [ -n "${toString paths.pgHbaUsersPublicConfigFile}" ]; then
144+
cp ${paths.pgHbaUsersPublicConfigFile} $out/etc/postgresql/pg_hba_users_public.conf || { echo "Failed to copy pg_hba_users_public.conf"; exit 1; }
145+
fi
146+
if [ -n "${toString paths.pgHbaPublicConfigFile}" ]; then
147+
cp ${paths.pgHbaPublicConfigFile} $out/etc/postgresql/pg_hba_public.conf || { echo "Failed to copy pg_hba_public.conf"; exit 1; }
148+
fi
128149
cp ${paths.pgIdentConfigFile} $out/etc/postgresql/pg_ident.conf || { echo "Failed to copy pg_ident.conf"; exit 1; }
129150
cp -r ${paths.postgresqlExtensionCustomScriptsPath}/* $out/extension-custom-scripts/ || { echo "Failed to copy custom scripts"; exit 1; }
130151
@@ -133,8 +154,13 @@
133154
chmod 644 $out/etc/postgresql/postgresql.conf
134155
chmod 644 $out/etc/postgresql-custom/logging.conf
135156
chmod 644 $out/etc/postgresql/pg_hba.conf
136-
chmod 644 $out/etc/postgresql/pg_hba_users_public.conf
137-
chmod 644 $out/etc/postgresql/pg_hba_public.conf
157+
158+
if [ -n "${toString paths.pgHbaUsersPublicConfigFile}" ]; then
159+
chmod 644 $out/etc/postgresql/pg_hba_users_public.conf
160+
fi
161+
if [ -n "${toString paths.pgHbaPublicConfigFile}" ]; then
162+
chmod 644 $out/etc/postgresql/pg_hba_public.conf
163+
fi
138164
139165
substitute ${../tools/run-server.sh.in} $out/bin/start-postgres-server \
140166
${

0 commit comments

Comments
 (0)