|
11 | 11 | majorVersion = lib.versions.major postgresql.version; |
12 | 12 | pkg = pkgs.buildEnv { |
13 | 13 | name = "postgresql-${majorVersion}-${pname}"; |
14 | | - paths = [ |
15 | | - postgresql |
16 | | - postgresql.lib |
17 | | - (installedExtension majorVersion) |
18 | | - self.packages.${pkgs.system}."psql_${majorVersion}/exts/postgis" |
19 | | - ]; |
| 14 | + paths = |
| 15 | + [ |
| 16 | + postgresql |
| 17 | + postgresql.lib |
| 18 | + (installedExtension majorVersion) |
| 19 | + self.packages.${pkgs.system}."psql_${majorVersion}/exts/postgis" |
| 20 | + ] |
| 21 | + ++ lib.optional (postgresql.isOrioleDB |
| 22 | + ) self.packages.${pkgs.system}."psql_orioledb-17/exts/orioledb"; |
20 | 23 | passthru = { |
21 | 24 | inherit (postgresql) version psqlSchema; |
22 | 25 | lib = pkg; |
@@ -106,16 +109,62 @@ self.inputs.nixpkgs.lib.nixos.runTest { |
106 | 109 | }; |
107 | 110 | }; |
108 | 111 |
|
| 112 | + specialisation.orioledb17.configuration = { |
| 113 | + services.postgresql = { |
| 114 | + package = lib.mkForce (postgresqlWithExtension self.packages.${pkgs.system}.postgresql_orioledb-17); |
| 115 | + settings = { |
| 116 | + shared_preload_libraries = "orioledb"; |
| 117 | + default_table_access_method = "orioledb"; |
| 118 | + }; |
| 119 | + initdbArgs = [ |
| 120 | + "--allow-group-access" |
| 121 | + "--locale-provider=icu" |
| 122 | + "--encoding=UTF-8" |
| 123 | + "--icu-locale=en_US.UTF-8" |
| 124 | + ]; |
| 125 | + initialScript = pkgs.writeText "init-postgres-with-orioledb" '' |
| 126 | + CREATE EXTENSION orioledb CASCADE; |
| 127 | + ''; |
| 128 | + }; |
| 129 | + |
| 130 | + systemd.services.postgresql-migrate = { |
| 131 | + # we don't support migrating from postgresql 17 to orioledb-17 so we just reinit the datadir |
| 132 | + serviceConfig = { |
| 133 | + Type = "oneshot"; |
| 134 | + RemainAfterExit = true; |
| 135 | + User = "postgres"; |
| 136 | + Group = "postgres"; |
| 137 | + StateDirectory = "postgresql"; |
| 138 | + WorkingDirectory = "${builtins.dirOf config.services.postgresql.dataDir}"; |
| 139 | + }; |
| 140 | + script = |
| 141 | + let |
| 142 | + newPostgresql = postgresqlWithExtension self.packages.${pkgs.system}.postgresql_orioledb-17; |
| 143 | + in |
| 144 | + '' |
| 145 | + set -x |
| 146 | + systemctl cat postgresql.service |
| 147 | + rm -rf ${builtins.dirOf config.services.postgresql.dataDir}/${newPostgresql.psqlSchema} |
| 148 | + ''; |
| 149 | + }; |
| 150 | + |
| 151 | + systemd.services.postgresql = { |
| 152 | + after = [ "postgresql-migrate.service" ]; |
| 153 | + requires = [ "postgresql-migrate.service" ]; |
| 154 | + }; |
| 155 | + }; |
109 | 156 | }; |
110 | 157 | testScript = |
111 | 158 | { nodes, ... }: |
112 | 159 | let |
113 | 160 | pg17-configuration = "${nodes.server.system.build.toplevel}/specialisation/postgresql17"; |
| 161 | + orioledb17-configuration = "${nodes.server.system.build.toplevel}/specialisation/orioledb17"; |
114 | 162 | in |
115 | 163 | '' |
116 | 164 | versions = { |
117 | 165 | "15": [${lib.concatStringsSep ", " (map (s: ''"${s}"'') (versions "15"))}], |
118 | 166 | "17": [${lib.concatStringsSep ", " (map (s: ''"${s}"'') (versions "17"))}], |
| 167 | + "orioledb-17": [${lib.concatStringsSep ", " (map (s: ''"${s}"'') (versions "orioledb-17"))}], |
119 | 168 | } |
120 | 169 |
|
121 | 170 | def run_sql(query): |
@@ -166,5 +215,14 @@ self.inputs.nixpkgs.lib.nixos.runTest { |
166 | 215 | assert f"${pname},{latestVersion}" in installed_extensions |
167 | 216 |
|
168 | 217 | check_upgrade_path("17") |
| 218 | +
|
| 219 | + with subtest("switch to orioledb 17"): |
| 220 | + server.succeed( |
| 221 | + "${orioledb17-configuration}/bin/switch-to-configuration test >&2" |
| 222 | + ) |
| 223 | + installed_extensions=run_sql(r"""SELECT extname FROM pg_extension WHERE extname = 'orioledb';""") |
| 224 | + assert "orioledb" in installed_extensions |
| 225 | +
|
| 226 | + check_upgrade_path("orioledb-17") |
169 | 227 | ''; |
170 | 228 | } |
0 commit comments