|
46 | 46 | #This variable works the same as 'oriole_pkgs' but builds using the upstream
|
47 | 47 | #nixpkgs builds of postgresql 15 and 16 + the overlays listed below
|
48 | 48 | pkgs = import nixpkgs {
|
49 |
| - config = { allowUnfree = true; }; |
| 49 | + config = { |
| 50 | + allowUnfree = true; |
| 51 | + permittedInsecurePackages = [ |
| 52 | + "v8-9.7.106.18" |
| 53 | + ]; |
| 54 | + }; |
50 | 55 | inherit system;
|
51 | 56 | overlays = [
|
52 | 57 | # NOTE (aseipp): add any needed overlays here. in theory we could
|
53 | 58 | # pull them from the overlays/ directory automatically, but we don't
|
54 | 59 | # want to have an arbitrary order, since it might matter. being
|
55 | 60 | # explicit is better.
|
| 61 | + (final: prev: { |
| 62 | + postgresql = final.callPackage ./nix/postgresql/default.nix { |
| 63 | + inherit (final) lib; |
| 64 | + inherit (final) stdenv; |
| 65 | + inherit (final) fetchurl; |
| 66 | + inherit (final) makeWrapper; |
| 67 | + inherit (final) callPackage; |
| 68 | + }; |
| 69 | + }) |
56 | 70 | (import ./nix/overlays/cargo-pgrx-0-11-3.nix)
|
57 | 71 | # (import ./nix/overlays/postgis.nix)
|
58 | 72 | #(import ./nix/overlays/gdal-small.nix)
|
59 | 73 |
|
60 | 74 | ];
|
61 | 75 | };
|
62 |
| - |
| 76 | + postgresql_15 = pkgs.postgresql.postgresql_15; |
| 77 | + postgresql = pkgs.postgresql.postgresql_15; |
63 | 78 | sfcgal = pkgs.callPackage ./nix/ext/sfcgal/sfcgal.nix { };
|
64 |
| - pg_regress = pkgs.callPackage ./nix/ext/pg_regress.nix { }; |
65 |
| - |
| 79 | + pg_regress = pkgs.callPackage ./nix/ext/pg_regress.nix { inherit postgresql; }; |
| 80 | + supabase-groonga = pkgs.callPackage ./nix/supabase-groonga.nix { }; |
| 81 | + mecab-naist-jdic = pkgs.callPackage ./nix/ext/mecab-naist-jdic/default.nix { }; |
66 | 82 | # Our list of PostgreSQL extensions which come from upstream Nixpkgs.
|
67 | 83 | # These are maintained upstream and can easily be used here just by
|
68 | 84 | # listing their name. Anytime the version of nixpkgs is upgraded, these
|
|
130 | 146 | #this var is a convenience setting to import the orioledb patched version of postgresql
|
131 | 147 | postgresql_orioledb_16 = oriole_pkgs.postgresql_orioledb_16;
|
132 | 148 | #postgis_override = pkgs.postgis_override;
|
133 |
| - |
| 149 | + getPostgresqlPackage = version: |
| 150 | + pkgs.postgresql."postgresql_${version}"; |
| 151 | + #we will add supported versions to this list in the future |
| 152 | + supportedVersions = [ "15" ]; |
134 | 153 | # Create a 'receipt' file for a given postgresql package. This is a way
|
135 | 154 | # of adding a bit of metadata to the package, which can be used by other
|
136 | 155 | # tools to inspect what the contents of the install are: the PSQL
|
|
172 | 191 | in map (path: pkgs.callPackage path { inherit postgresql; }) orioledbExtension;
|
173 | 192 |
|
174 | 193 | makeOurPostgresPkgs = version:
|
175 |
| - let postgresql = pkgs."postgresql_${version}"; |
| 194 | + let postgresql = getPostgresqlPackage version; |
176 | 195 | in map (path: pkgs.callPackage path { inherit postgresql; }) ourExtensions;
|
177 | 196 |
|
178 | 197 | # Create an attrset that contains all the extensions included in a server for the orioledb version of postgresql + extension.
|
|
204 | 223 | # basis for building extensions, etc.
|
205 | 224 | makePostgresBin = version:
|
206 | 225 | let
|
207 |
| - postgresql = pkgs."postgresql_${version}"; |
| 226 | + postgresql = getPostgresqlPackage version; |
208 | 227 | upstreamExts = map
|
209 | 228 | (ext: {
|
210 | 229 | name = postgresql.pkgs."${ext}".pname;
|
|
268 | 287 | # name in 'nix flake show' in order to make sure exactly what name you
|
269 | 288 | # want.
|
270 | 289 | basePackages = {
|
| 290 | + supabase-groonga = supabase-groonga; |
271 | 291 | # PostgreSQL versions.
|
272 | 292 | psql_15 = makePostgres "15";
|
273 | 293 | #psql_16 = makePostgres "16";
|
274 | 294 | #psql_orioledb_16 = makeOrioleDbPostgres "16_23" postgresql_orioledb_16;
|
275 | 295 | sfcgal = sfcgal;
|
276 | 296 | pg_regress = pg_regress;
|
277 | 297 | pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP;
|
| 298 | + postgresql_15 = pkgs.postgresql_15; |
| 299 | + |
| 300 | + postgresql_15_src = pkgs.stdenv.mkDerivation { |
| 301 | + pname = "postgresql-15-src"; |
| 302 | + version = pkgs.postgresql_15.version; |
| 303 | + |
| 304 | + src = pkgs.postgresql_15.src; |
| 305 | + |
| 306 | + nativeBuildInputs = [ pkgs.bzip2 ]; |
| 307 | + |
| 308 | + phases = [ "unpackPhase" "installPhase" ]; |
| 309 | + |
| 310 | + installPhase = '' |
| 311 | + mkdir -p $out |
| 312 | + cp -r . $out |
| 313 | + ''; |
| 314 | + |
| 315 | + meta = with pkgs.lib; { |
| 316 | + description = "PostgreSQL 15 source files"; |
| 317 | + homepage = "https://www.postgresql.org/"; |
| 318 | + license = licenses.postgresql; |
| 319 | + platforms = platforms.all; |
| 320 | + }; |
| 321 | + }; |
| 322 | + mecab_naist_jdic = mecab-naist-jdic; |
| 323 | + supabase_groonga = supabase-groonga; |
278 | 324 | # Start a version of the server.
|
279 | 325 | start-server =
|
280 | 326 | let
|
|
302 | 348 | name = "pg_ident.conf";
|
303 | 349 | path = ./ansible/files/postgresql_config/pg_ident.conf.j2;
|
304 | 350 | };
|
| 351 | + postgresqlExtensionCustomScriptsPath = builtins.path { |
| 352 | + name = "extension-custom-scripts"; |
| 353 | + path = ./ansible/files/postgresql_extension_custom_scripts; |
| 354 | + }; |
305 | 355 | getkeyScript = ./nix/tests/util/pgsodium_getkey.sh;
|
306 | 356 | localeArchive = if pkgs.stdenv.isDarwin
|
307 | 357 | then "${pkgs.darwin.locale}/share/locale"
|
308 | 358 | else "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
309 | 359 | in
|
310 | 360 | pkgs.runCommand "start-postgres-server" { } ''
|
311 |
| - mkdir -p $out/bin $out/etc/postgresql-custom $out/etc/postgresql |
| 361 | + mkdir -p $out/bin $out/etc/postgresql-custom $out/etc/postgresql $out/extension-custom-scripts |
312 | 362 | cp ${supautilsConfigFile} $out/etc/postgresql-custom/supautils.conf || { echo "Failed to copy supautils.conf"; exit 1; }
|
313 | 363 | cp ${pgconfigFile} $out/etc/postgresql/postgresql.conf || { echo "Failed to copy postgresql.conf"; exit 1; }
|
314 | 364 | cp ${loggingConfigFile} $out/etc/postgresql-custom/logging.conf || { echo "Failed to copy logging.conf"; exit 1; }
|
315 | 365 | cp ${readReplicaConfigFile} $out/etc/postgresql-custom/read-replica.conf || { echo "Failed to copy read-replica.conf"; exit 1; }
|
316 | 366 | cp ${pgHbaConfigFile} $out/etc/postgresql/pg_hba.conf || { echo "Failed to copy pg_hba.conf"; exit 1; }
|
317 | 367 | cp ${pgIdentConfigFile} $out/etc/postgresql/pg_ident.conf || { echo "Failed to copy pg_ident.conf"; exit 1; }
|
| 368 | + cp -r ${postgresqlExtensionCustomScriptsPath}/* $out/extension-custom-scripts/ || { echo "Failed to copy custom scripts"; exit 1; } |
318 | 369 | echo "Copy operation completed"
|
319 | 370 | chmod 644 $out/etc/postgresql-custom/supautils.conf
|
320 | 371 | chmod 644 $out/etc/postgresql/postgresql.conf
|
|
331 | 382 | --subst-var-by 'SUPAUTILS_CONF_FILE' "$out/etc/postgresql-custom/supautils.conf" \
|
332 | 383 | --subst-var-by 'PG_HBA' "$out/etc/postgresql/pg_hba.conf" \
|
333 | 384 | --subst-var-by 'PG_IDENT' "$out/etc/postgresql/pg_ident.conf" \
|
334 |
| - --subst-var-by 'LOCALES' '${localeArchive}' |
335 |
| - |
| 385 | + --subst-var-by 'LOCALES' '${localeArchive}' \ |
| 386 | + --subst-var-by 'EXTENSION_CUSTOM_SCRIPTS_DIR' "$out/extension-custom-scripts" \ |
| 387 | + --subst-var-by 'MECAB_LIB' '${basePackages.psql_15.exts.pgroonga}/lib/groonga/plugins/tokenizers/tokenizer_mecab.so' \ |
| 388 | + --subst-var-by 'GROONGA_DIR' '${supabase-groonga}' |
| 389 | +
|
336 | 390 | chmod +x $out/bin/start-postgres-server
|
337 | 391 | '';
|
338 | 392 |
|
339 |
| - # Start a version of the client. |
340 |
| - start-client = pkgs.runCommand "start-postgres-client" { } '' |
341 |
| - mkdir -p $out/bin |
342 |
| - substitute ${./nix/tools/run-client.sh.in} $out/bin/start-postgres-client \ |
343 |
| - --subst-var-by 'PGSQL_DEFAULT_PORT' '${pgsqlDefaultPort}' \ |
344 |
| - --subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \ |
345 |
| - --subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' |
346 |
| - chmod +x $out/bin/start-postgres-client |
347 |
| - ''; |
348 |
| - |
349 | 393 | # Start a version of the client and runs migrations script on server.
|
350 |
| - start-client-and-migrate = |
| 394 | + start-client = |
351 | 395 | let
|
352 | 396 | migrationsDir = ./migrations/db;
|
353 | 397 | postgresqlSchemaSql = ./nix/tools/postgresql_schema.sql;
|
354 | 398 | pgbouncerAuthSchemaSql = ./ansible/files/pgbouncer_config/pgbouncer_auth_schema.sql;
|
355 | 399 | statExtensionSql = ./ansible/files/stat_extension.sql;
|
356 | 400 | in
|
357 |
| - pkgs.runCommand "start-postgres-client-migrate" { } '' |
| 401 | + pkgs.runCommand "start-postgres-client" { } '' |
358 | 402 | mkdir -p $out/bin
|
359 |
| - substitute ${./nix/tools/run-client-migrate.sh.in} $out/bin/start-postgres-client-migrate \ |
| 403 | + substitute ${./nix/tools/run-client.sh.in} $out/bin/start-postgres-client \ |
360 | 404 | --subst-var-by 'PGSQL_DEFAULT_PORT' '${pgsqlDefaultPort}' \
|
361 | 405 | --subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \
|
362 | 406 | --subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' \
|
363 | 407 | --subst-var-by 'MIGRATIONS_DIR' '${migrationsDir}' \
|
364 | 408 | --subst-var-by 'POSTGRESQL_SCHEMA_SQL' '${postgresqlSchemaSql}' \
|
365 | 409 | --subst-var-by 'PGBOUNCER_AUTH_SCHEMA_SQL' '${pgbouncerAuthSchemaSql}' \
|
366 | 410 | --subst-var-by 'STAT_EXTENSION_SQL' '${statExtensionSql}'
|
367 |
| - chmod +x $out/bin/start-postgres-client-migrate |
| 411 | + chmod +x $out/bin/start-postgres-client |
368 | 412 | '';
|
369 | 413 |
|
370 | 414 | # Migrate between two data directories.
|
|
412 | 456 | let
|
413 | 457 | sqlTests = ./nix/tests/smoke;
|
414 | 458 | pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP;
|
| 459 | + supabase-groonga = pkgs.callPackage ./nix/supabase-groonga.nix { }; |
415 | 460 | in
|
416 | 461 | pkgs.runCommand "postgres-${pgpkg.version}-check-harness"
|
417 | 462 | {
|
418 |
| - nativeBuildInputs = with pkgs; [ coreutils bash pgpkg pg_prove pg_regress procps ]; |
| 463 | + nativeBuildInputs = with pkgs; [ coreutils bash pgpkg pg_prove pg_regress procps supabase-groonga ]; |
419 | 464 | } ''
|
420 | 465 | TMPDIR=$(mktemp -d)
|
421 | 466 | if [ $? -ne 0 ]; then
|
|
433 | 478 | mkdir -p $TMPDIR/logfile
|
434 | 479 | # Generate a random key and store it in an environment variable
|
435 | 480 | export PGSODIUM_KEY=$(head -c 32 /dev/urandom | od -A n -t x1 | tr -d ' \n')
|
436 |
| -
|
| 481 | + export GRN_PLUGINS_DIR=${supabase-groonga}/lib/groonga/plugins |
437 | 482 | # Create a simple script to echo the key
|
438 | 483 | echo '#!/bin/sh' > $TMPDIR/getkey.sh
|
439 | 484 | echo 'echo $PGSODIUM_KEY' >> $TMPDIR/getkey.sh
|
|
519 | 564 | {
|
520 | 565 | start-server = mkApp "start-server" "start-postgres-server";
|
521 | 566 | start-client = mkApp "start-client" "start-postgres-client";
|
522 |
| - start-client-and-migrate = mkApp "start-client-and-migrate" "start-postgres-client-migrate"; |
523 | 567 | start-replica = mkApp "start-replica" "start-postgres-replica";
|
524 | 568 | migration-test = mkApp "migrate-tool" "migrate-postgres";
|
525 | 569 | sync-exts-versions = mkApp "sync-exts-versions" "sync-exts-versions";
|
|
0 commit comments