diff --git a/.github/workflows/ami-release-nix.yml b/.github/workflows/ami-release-nix.yml index 643f26fc7..f7005a4b0 100644 --- a/.github/workflows/ami-release-nix.yml +++ b/.github/workflows/ami-release-nix.yml @@ -3,8 +3,9 @@ name: Release AMI Nix on: push: branches: - - develop - - release/* + #- develop + #- release/* + - sam/oriole16 paths: - '.github/workflows/ami-release-nix.yml' - 'common-nix.vars.pkr.hcl' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1457eb100..c58df7d15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,8 @@ on: push: branches: - develop - pull_request: + #TODO PR uncomment this line + #pull_request: workflow_dispatch: jobs: diff --git a/ansible/tasks/stage2-setup-postgres.yml b/ansible/tasks/stage2-setup-postgres.yml index e22cbe67b..f1082347f 100644 --- a/ansible/tasks/stage2-setup-postgres.yml +++ b/ansible/tasks/stage2-setup-postgres.yml @@ -3,11 +3,33 @@ # shell: | # sudo -u postgres bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install nixpkgs#openjdk11" # It was decided to leave pljava disabled at https://github.com/supabase/postgres/pull/690 therefore removing this task + +- name: Check psql_version and modify supautils.conf and postgresql.conf if necessary + block: + - name: Check if psql_version is psql_orioledb-16 + set_fact: + is_psql_oriole_16: "{{ psql_version == 'psql_orioledb-16' }}" + + - name: Remove specified extensions from postgresql.conf if oriole-16 build + ansible.builtin.command: + cmd: > + sed -i 's/ timescaledb,//g' + /etc/postgresql/postgresql.conf + when: is_psql_oriole_16 and stage2_nix + become: yes + + - name: Remove specified extensions from supautils.conf if oriole-16 build + ansible.builtin.command: + cmd: > + sed -i 's/ timescaledb,//g; s/ vector,//g; s/ plv8,//g; s/ postgis,//g; s/ pgrouting,//g' + /etc/postgresql-custom/supautils.conf + when: is_psql_oriole_16 and stage2_nix + become: yes + - name: Install Postgres from nix binary cache become: yes shell: | sudo -u postgres bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#{{psql_version}}/bin" -#TODO (samrose) switch pg_prove sourcing to develop branch once PR is merged when: stage2_nix - name: Install pg_prove from nix binary cache @@ -198,13 +220,19 @@ recurse: yes when: stage2_nix -- name: Recursively create symbolic links and set permissions for the contrib/postgis-* dir - shell: > - sudo mkdir -p /usr/lib/postgresql/share/postgresql/contrib && \ - sudo find /var/lib/postgresql/.nix-profile/share/postgresql/contrib/ -mindepth 1 -type d -exec sh -c 'for dir do sudo ln -s "$dir" "/usr/lib/postgresql/share/postgresql/contrib/$(basename "$dir")"; done' sh {} + \ - && chown -R postgres:postgres "/usr/lib/postgresql/share/postgresql/contrib/" - become: yes - when: stage2_nix +- name: Check psql_version and run postgis linking if not oriole-16 + block: + - name: Check if psql_version is psql_orioledb-16 + set_fact: + is_psql_oriole_16: "{{ psql_version == 'psql_orioledb-16' }}" + + - name: Recursively create symbolic links and set permissions for the contrib/postgis-* dir + shell: > + sudo mkdir -p /usr/lib/postgresql/share/postgresql/contrib && \ + sudo find /var/lib/postgresql/.nix-profile/share/postgresql/contrib/ -mindepth 1 -type d -exec sh -c 'for dir do sudo ln -s "$dir" "/usr/lib/postgresql/share/postgresql/contrib/$(basename "$dir")"; done' sh {} + \ + && chown -R postgres:postgres "/usr/lib/postgresql/share/postgresql/contrib/" + become: yes + when: stage2_nix and not is_psql_oriole_16 - name: Create symbolic links from /var/lib/postgresql/.nix-profile/share/postgresql/timezonesets to /usr/lib/postgresql/share/postgresql/timeszonesets file: @@ -239,8 +267,17 @@ line: pgsodium.getkey_script= '{{ pg_bindir }}/pgsodium_getkey.sh' when: stage2_nix +#TODO PR may need to remove this. +- name: Create symbolic link for pgsodium_getkey script + file: + src: "/usr/lib/postgresql/bin/pgsodium_getkey.sh" + dest: "/usr/lib/postgresql/share/postgresql/extension/pgsodium_getkey" + state: link + become: yes + when: stage2_nix + - name: Append GRN_PLUGINS_DIR to /etc/environment.d/postgresql.env ansible.builtin.lineinfile: path: /etc/environment.d/postgresql.env line: 'GRN_PLUGINS_DIR=/var/lib/postgresql/.nix-profile/lib/groonga/plugins' - become: yes \ No newline at end of file + become: yes diff --git a/ansible/tasks/test-image.yml b/ansible/tasks/test-image.yml index d6e8223f7..40a208136 100644 --- a/ansible/tasks/test-image.yml +++ b/ansible/tasks/test-image.yml @@ -4,11 +4,22 @@ - libtap-parser-sourcehandler-pgtap-perl when: debpkg_mode +# - name: Temporarily disable PG Sodium references in config +# become: yes +# become_user: postgres +# shell: +# cmd: sed -i.bak -e "s/pg_net,\ pgsodium,\ timescaledb/pg_net,\ timescaledb/g" -e "s/pgsodium.getkey_script=/#pgsodium.getkey_script=/g" /etc/postgresql/postgresql.conf +# when: debpkg_mode or stage2_nix + - name: Temporarily disable PG Sodium references in config become: yes become_user: postgres shell: - cmd: sed -i.bak -e "s/pg_net,\ pgsodium,\ timescaledb/pg_net,\ timescaledb/g" -e "s/pgsodium.getkey_script=/#pgsodium.getkey_script=/g" /etc/postgresql/postgresql.conf + cmd: > + sed -i.bak + -e 's/\(shared_preload_libraries = '\''.*\)pgsodium,\(.*'\''\)/\1\2/' + -e 's/pgsodium.getkey_script=/#pgsodium.getkey_script=/' + /etc/postgresql/postgresql.conf when: debpkg_mode or stage2_nix - name: Start Postgres Database to load all extensions. @@ -52,6 +63,40 @@ failed_when: retval.rc != 0 when: debpkg_mode or stage2_nix +- name: Check psql_version and modify migrations if orioe-16 + block: + - name: Check if psql_version is psql_orioledb-16 + set_fact: + is_psql_oriole_16: "{{ psql_version == 'psql_orioledb-16' }}" + + - name: Remove specified extensions from SQL file + ansible.builtin.command: + cmd: > + sed -i '/\\ir.*\(timescaledb\|postgis\|pgrouting\|plv8\|pgvector\).*\.sql/d' /tmp/migrations/tests/extensions/test.sql + when: is_psql_oriole_16 + become: yes + + - name: Remove specified extension files from extensions directory + ansible.builtin.find: + paths: /tmp/migrations/tests/extensions + patterns: + - '*timescaledb*.sql' + - '*postgis*.sql' + - '*pgrouting*.sql' + - '*plv8*.sql' + - '*pgvector*.sql' + register: files_to_remove + when: is_psql_oriole_16 + + - name: Delete matched extension files + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: "{{ files_to_remove.files }}" + when: is_psql_oriole_16 + become: yes + + - name: Run migrations tests shell: /usr/bin/pg_prove -U supabase_admin -h localhost -d postgres -v tests/test.sql register: retval diff --git a/ansible/vars.yml b/ansible/vars.yml index 129e1a238..14b35ef69 100644 --- a/ansible/vars.yml +++ b/ansible/vars.yml @@ -2,17 +2,17 @@ supabase_internal: true ebssurrogate_mode: true async_mode: true -# postgresql_major: "15" -# postgresql_release: "15.1" -# postgresql_release_checksum: sha256:ea2cf059a85882654b989acd07edc121833164a30340faee0d3615cf7058e66c postgres_major: - - "15" - - "16" + #- "15" + #- "16" + - "orioledb-16" # Full version strings for each major version +# TOD PR uncomment these lines postgres_release: - postgres15: "15.8.1.004" - postgres16: "16.3.1.010" + #postgres15: "15.8.1.003-staging-5" + #postgres16: "16.3.1.000-staging-5" + postgresorioledb-16: "orioledb-16.3.1.000-staging-12" # Non Postgres Extensions pgbouncer_release: "1.19.0" diff --git a/docker/nix/build_nix.sh b/docker/nix/build_nix.sh index 3cf8505c0..7213333f0 100644 --- a/docker/nix/build_nix.sh +++ b/docker/nix/build_nix.sh @@ -7,7 +7,10 @@ if [ -d "/workspace" ]; then fi nix build .#checks.$(nix-instantiate --eval -E builtins.currentSystem | tr -d '"').psql_15 -L --no-link nix build .#checks.$(nix-instantiate --eval -E builtins.currentSystem | tr -d '"').psql_16 -L --no-link +#no nix flake check on oriole yet nix build .#psql_15/bin -o psql_15 nix build .#psql_16/bin -o psql_16 +nix build .#psql_orioledb-16/bin -o psql_orioledb_16 nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_15 nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_16 +nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_orioledb_16 diff --git a/flake.nix b/flake.nix index 3014f9032..ef1324eb8 100644 --- a/flake.nix +++ b/flake.nix @@ -25,26 +25,6 @@ pgsqlSuperuser = "supabase_admin"; nix2img = nix2container.packages.${system}.nix2container; - # The 'oriole_pkgs' variable holds all the upstream packages in nixpkgs, which - # we can use to build our own images; it is the common name to refer to - # a copy of nixpkgs which contains all its packages. - # it also serves as a base for importing the orioldb/postgres overlay to - #build the orioledb postgres patched version of postgresql16 - oriole_pkgs = import nixpkgs { - config = { allowUnfree = true; }; - inherit system; - overlays = [ - # NOTE (aseipp): add any needed overlays here. in theory we could - # pull them from the overlays/ directory automatically, but we don't - # want to have an arbitrary order, since it might matter. being - # explicit is better. - (import ./nix/overlays/cargo-pgrx.nix) - (import ./nix/overlays/psql_16-oriole.nix) - - ]; - }; - #This variable works the same as 'oriole_pkgs' but builds using the upstream - #nixpkgs builds of postgresql 15 and 16 + the overlays listed below pkgs = import nixpkgs { config = { allowUnfree = true; @@ -54,7 +34,7 @@ }; inherit system; overlays = [ - # NOTE add any needed overlays here. in theory we could + # NOTE: add any needed overlays here. in theory we could # pull them from the overlays/ directory automatically, but we don't # want to have an arbitrary order, since it might matter. being # explicit is better. @@ -91,11 +71,7 @@ }) (final: prev: { postgresql = final.callPackage ./nix/postgresql/default.nix { - inherit (final) lib; - inherit (final) stdenv; - inherit (final) fetchurl; - inherit (final) makeWrapper; - inherit (final) callPackage; + inherit (final) lib stdenv fetchurl makeWrapper callPackage buildEnv newScope; }; }) ]; @@ -171,13 +147,22 @@ in baseExtensions ++ pgNetExtension; #Where we import and build the orioledb extension, we add on our custom extensions # plus the orioledb option - orioledbExtension = ourExtensions ++ [ ./nix/ext/orioledb.nix ]; + #we're not using timescaledb in the orioledb version of supabase extensions + orioleFilteredExtensions = builtins.filter ( + x: + x != ./nix/ext/timescaledb.nix && + x != ./nix/ext/pgvector.nix && + x != ./nix/ext/plv8.nix && + x != ./nix/ext/postgis.nix && + x != ./nix/ext/pgrouting.nix + ) ourExtensions; + + orioledbExtensions = orioleFilteredExtensions ++ [ ./nix/ext/orioledb.nix ]; - #this var is a convenience setting to import the orioledb patched version of postgresql - postgresql_orioledb_16 = oriole_pkgs.postgresql_orioledb_16; - #postgis_override = pkgs.postgis_override; getPostgresqlPackage = version: - pkgs.postgresql."postgresql_${version}"; + if version == "orioledb_16" + then pkgs.postgresql."postgresql_orioledb-16" + else pkgs.postgresql."postgresql_${version}"; # Create a 'receipt' file for a given postgresql package. This is a way # of adding a bit of metadata to the package, which can be used by other # tools to inspect what the contents of the install are: the PSQL @@ -206,7 +191,7 @@ }; extensions = ourExts; - # NOTE (aseipp): this field can be used to do cache busting (e.g. + # NOTE this field can be used to do cache busting (e.g. # force a rebuild of the psql packages) but also to helpfully inform # tools what version of the schema is being used, for forwards and # backwards compatibility @@ -214,22 +199,14 @@ }; }; - makeOurOrioleDbPostgresPkgs = version: patchedPostgres: - let postgresql = patchedPostgres; - in map (path: pkgs.callPackage path { inherit postgresql; }) orioledbExtension; - makeOurPostgresPkgs = version: - let postgresql = getPostgresqlPackage version; - in map (path: pkgs.callPackage path { inherit postgresql; }) ourExtensions; + let + postgresql = getPostgresqlPackage version; + extensionsToUse = if version == "orioledb-16" + then orioledbExtensions + else ourExtensions; + in map (path: pkgs.callPackage path { inherit postgresql; }) extensionsToUse; - # Create an attrset that contains all the extensions included in a server for the orioledb version of postgresql + extension. - makeOurOrioleDbPostgresPkgsSet = version: patchedPostgres: - (builtins.listToAttrs (map - (drv: - { name = drv.pname; value = drv; } - ) - (makeOurOrioleDbPostgresPkgs version patchedPostgres))) - // { recurseForDerivations = true; }; # Create an attrset that contains all the extensions included in a server. makeOurPostgresPkgsSet = version: @@ -269,27 +246,6 @@ paths = [ pgbin (makeReceipt pgbin upstreamExts ourExts) ]; }; - makeOrioleDbPostgresBin = version: patchedPostgres: - let - postgresql = patchedPostgres; - upstreamExts = map - (ext: { - name = postgresql.pkgs."${ext}".pname; - version = postgresql.pkgs."${ext}".version; - }) - orioledbPsqlExtensions; - ourExts = map (ext: { name = ext.pname; version = ext.version; }) (makeOurOrioleDbPostgresPkgs version postgresql); - - pgbin = postgresql.withPackages (ps: - (map (ext: ps."${ext}") orioledbPsqlExtensions) ++ (makeOurOrioleDbPostgresPkgs version postgresql) - ); - in - pkgs.symlinkJoin { - inherit (pgbin) name version; - paths = [ pgbin (makeReceipt pgbin upstreamExts ourExts) ]; - }; - - # Create an attribute set, containing all the relevant packages for a # PostgreSQL install, wrapped up with a bow on top. There are three # packages: @@ -304,11 +260,6 @@ exts = makeOurPostgresPkgsSet version; recurseForDerivations = true; }; - makeOrioleDbPostgres = version: patchedPostgres: rec { - bin = makeOrioleDbPostgresBin version patchedPostgres; - exts = makeOurOrioleDbPostgresPkgsSet version patchedPostgres; - recurseForDerivations = true; - }; # The base set of packages that we export from this Nix Flake, that can # be used with 'nix build'. Don't use the names listed below; check the @@ -326,7 +277,7 @@ postgresVersions = { psql_15 = makePostgres "15"; psql_16 = makePostgres "16"; - # psql_orioledb_16 = makeOrioleDbPostgres "16_23" postgresql_orioledb_16; + psql_orioledb-16 = makePostgres "orioledb-16" ; }; # Find the active PostgreSQL version @@ -342,6 +293,7 @@ }; postgresql_15 = getPostgresqlPackage "15"; postgresql_16 = getPostgresqlPackage "16"; + postgresql_orioledb-16 = getPostgresqlPackage "orioledb-16"; in postgresVersions //{ supabase-groonga = supabase-groonga; @@ -350,12 +302,13 @@ # PostgreSQL versions. psql_15 = postgresVersions.psql_15; psql_16 = postgresVersions.psql_16; - #psql_orioledb_16 = makeOrioleDbPostgres "16_23" postgresql_orioledb_16; + psql_orioledb-16 = postgresVersions.psql_orioledb-16; sfcgal = sfcgal; pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP; - inherit postgresql_15 postgresql_16; + inherit postgresql_15 postgresql_16 postgresql_orioledb-16; postgresql_15_debug = if pkgs.stdenv.isLinux then postgresql_15.debug else null; postgresql_16_debug = if pkgs.stdenv.isLinux then postgresql_16.debug else null; + postgresql_orioledb-16_debug = if pkgs.stdenv.isLinux then postgresql_orioledb-16.debug else null; postgresql_15_src = pkgs.stdenv.mkDerivation { pname = "postgresql-15-src"; version = postgresql_15.version; @@ -400,6 +353,28 @@ platforms = platforms.all; }; }; + postgresql_orioledb-16_src = pkgs.stdenv.mkDerivation { + pname = "postgresql-16-src"; + version = postgresql_orioledb-16.version; + + src = postgresql_16.src; + + nativeBuildInputs = [ pkgs.bzip2 ]; + + phases = [ "unpackPhase" "installPhase" ]; + + installPhase = '' + mkdir -p $out + cp -r . $out + ''; + + meta = with pkgs.lib; { + description = "PostgreSQL 15 source files"; + homepage = "https://www.postgresql.org/"; + license = licenses.postgresql; + platforms = platforms.all; + }; + }; mecab_naist_jdic = mecab-naist-jdic; supabase_groonga = supabase-groonga; pg_regress = makePgRegress activeVersion; @@ -459,6 +434,7 @@ --subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' \ --subst-var-by 'PSQL_CONF_FILE' $out/etc/postgresql/postgresql.conf \ --subst-var-by 'PSQL16_BINDIR' '${basePackages.psql_16.bin}' \ + --subst-var-by 'PSQLORIOLEDB16_BINDIR' '${basePackages.psql_orioledb-16.bin}' \ --subst-var-by 'PGSODIUM_GETKEY' '${getkeyScript}' \ --subst-var-by 'READREPL_CONF_FILE' "$out/etc/postgresql-custom/read-replica.conf" \ --subst-var-by 'LOGGING_CONF_FILE' "$out/etc/postgresql-custom/logging.conf" \ @@ -489,6 +465,7 @@ --subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \ --subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' \ --subst-var-by 'PSQL16_BINDIR' '${basePackages.psql_16.bin}' \ + --subst-var-by 'PSQLORIOLEDB16_BINDIR' '${basePackages.psql_orioledb-16.bin}' \ --subst-var-by 'MIGRATIONS_DIR' '${migrationsDir}' \ --subst-var-by 'POSTGRESQL_SCHEMA_SQL' '${postgresqlSchemaSql}' \ --subst-var-by 'PGBOUNCER_AUTH_SCHEMA_SQL' '${pgbouncerAuthSchemaSql}' \ diff --git a/nix/ext/orioledb.nix b/nix/ext/orioledb.nix index 4d8c51bbd..ff7c12a96 100644 --- a/nix/ext/orioledb.nix +++ b/nix/ext/orioledb.nix @@ -6,17 +6,17 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "orioledb"; repo = "orioledb"; - rev = "main"; - sha256 = "sha256-QbDp9S8JXO66sfaHZIQ3wFCVRxsAaaNSRgC6hvL3EKY="; + rev = "bd8e32d0ebaafd0ea3ec3074233b65167f3b6fb7"; + sha256 = "sha256-bzH1SgPZ6q90HpqRsECY2XQPghEcd2Hg4X55G43unNo="; }; - version = "patches16_23"; + version = "patches16_31"; buildInputs = [ curl libkrb5 postgresql python3 openssl ]; - buildPhase = "make USE_PGXS=1 ORIOLEDB_PATCHSET_VERSION=23"; + buildPhase = "make USE_PGXS=1 ORIOLEDB_PATCHSET_VERSION=31"; installPhase = '' runHook preInstall mkdir -p $out/{lib,share/postgresql/extension} - cp *.so $out/lib + cp *${postgresql.dlSuffix} $out/lib cp *.sql $out/share/postgresql/extension cp *.control $out/share/postgresql/extension diff --git a/nix/ext/wrappers/default.nix b/nix/ext/wrappers/default.nix index 74b94f9f9..d53604a5d 100644 --- a/nix/ext/wrappers/default.nix +++ b/nix/ext/wrappers/default.nix @@ -49,10 +49,46 @@ buildPgrxExtension_0_12_6 rec { CARGO_BUILD_JOBS = "2"; CARGO="${cargo}/bin/cargo"; + #CARGO_NET_GIT_FETCH_WITH_CLI = "true"; cargoLock = { lockFile = "${src}/Cargo.lock"; allowBuiltinFetchGit = true; }; + + preConfigure = '' + cd wrappers + + # update the clickhouse-rs dependency + # append the branch name to the git URL to help cargo locate the commit + # while maintaining the rev for reproducibility + awk -i inplace ' + /\[dependencies.clickhouse-rs\]/ { + print + getline + if ($0 ~ /git =/) { + print "git = \"https://github.com/suharev7/clickhouse-rs/async-await\"" + } else { + print + } + while ($0 !~ /^\[/ && NF > 0) { + getline + if ($0 ~ /rev =/) print + if ($0 ~ /^\[/) print + } + next + } + { print } + ' Cargo.toml + + # Verify the file is still valid TOML, break build with this error + # if it is not + if ! cargo verify-project 2>/dev/null; then + echo "Failed to maintain valid TOML syntax" + exit 1 + fi + + cd .. + ''; buildAndTestSubdir = "wrappers"; buildFeatures = [ diff --git a/nix/overlays/psql_16-oriole.nix b/nix/overlays/psql_16-oriole.nix index d55af10a2..309129f1f 100644 --- a/nix/overlays/psql_16-oriole.nix +++ b/nix/overlays/psql_16-oriole.nix @@ -1,10 +1,10 @@ final: prev: { - postgresql_16 = prev.postgresql_16.overrideAttrs (old: { - pname = "postgresql_16"; - version = "16_23"; + pg_orioledb = prev.postgresql_16.overrideAttrs (old: { + pname = "postgresql_orioledb"; + version = "16_31"; src = prev.fetchurl { - url = "https://github.com/orioledb/postgres/archive/refs/tags/patches16_23.tar.gz"; - sha256 = "sha256-xWmcqn3DYyBG0FsBNqPWTFzUidSJZgoPWI6Rt0N9oJ4="; + url = "https://github.com/orioledb/postgres/archive/refs/tags/patches16_31.tar.gz"; + sha256 = "sha256-29uHUACwZKh8e4zJ9tWzEhLNjEuh6P31KbpxnMEhtuI="; }; buildInputs = old.buildInputs ++ [ prev.bison @@ -17,5 +17,5 @@ final: prev: { prev.perl ]; }); - postgresql_orioledb_16 = final.postgresql_16; + postgresql_orioledb = final.pg_orioledb; } diff --git a/nix/postgresql/default.nix b/nix/postgresql/default.nix index 5f92262b2..484cac777 100644 --- a/nix/postgresql/default.nix +++ b/nix/postgresql/default.nix @@ -1,11 +1,10 @@ self: let - #adapted from the postgresql nixpkgs package versions = { postgresql_15 = ./15.nix; postgresql_16 = ./16.nix; + postgresql_orioledb-16 = ./orioledb-16.nix; }; - mkAttributes = jitSupport: self.lib.mapAttrs' (version: path: let @@ -15,7 +14,6 @@ let inherit jitSupport self; }) ) versions; - in # variations without and with JIT (mkAttributes false) // (mkAttributes true) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 323b65167..c03d1bcb3 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -7,6 +7,8 @@ let , glibc, zlib, readline, openssl, icu, lz4, zstd, systemd, libossp_uuid , pkg-config, libxml2, tzdata, libkrb5, substituteAll, darwin , linux-pam + #orioledb specific + , perl, bison, flex, docbook_xsl, docbook_xml_dtd_45, docbook_xsl_ns, libxslt # This is important to obtain a version of `libpq` that does not depend on systemd. , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd && !stdenv.hostPlatform.isStatic @@ -49,10 +51,16 @@ let inherit version; pname = pname + lib.optionalString jitSupport "-jit"; - src = fetchurl { - url = "mirror://postgresql/source/v${version}/${pname}-${version}.tar.bz2"; - inherit hash; - }; + src = if (builtins.match "16_.*" version != null) then + fetchurl { + url = "https://github.com/orioledb/postgres/archive/refs/tags/patches${version}.tar.gz"; + inherit hash; + } + else + fetchurl { + url = "mirror://postgresql/source/v${version}/${pname}-${version}.tar.bz2"; + inherit hash; + }; hardeningEnable = lib.optionals (!stdenv'.cc.isClang) [ "pie" ]; @@ -74,7 +82,10 @@ let ++ lib.optionals pythonSupport [ python3 ] ++ lib.optionals gssSupport [ libkrb5 ] ++ lib.optionals stdenv'.isLinux [ linux-pam ] - ++ lib.optionals (!stdenv'.isDarwin) [ libossp_uuid ]; + ++ lib.optionals (!stdenv'.isDarwin) [ libossp_uuid ] + ++ lib.optionals (builtins.match "16_.*" version != null) [ + perl bison flex docbook_xsl docbook_xml_dtd_45 docbook_xsl_ns libxslt + ]; nativeBuildInputs = [ makeWrapper diff --git a/nix/postgresql/orioledb-16.nix b/nix/postgresql/orioledb-16.nix new file mode 100644 index 000000000..e9a66850e --- /dev/null +++ b/nix/postgresql/orioledb-16.nix @@ -0,0 +1,4 @@ +import ./generic.nix { + version = "16_31"; + hash = "sha256-29uHUACwZKh8e4zJ9tWzEhLNjEuh6P31KbpxnMEhtuI="; +} diff --git a/nix/tools/run-server.sh.in b/nix/tools/run-server.sh.in index 2552ebcd6..085b480bc 100644 --- a/nix/tools/run-server.sh.in +++ b/nix/tools/run-server.sh.in @@ -1,7 +1,7 @@ #!/usr/bin/env bash # shellcheck shell=bash [ ! -z "$DEBUG" ] && set -x -# first argument should be '15' or '16' for the version + if [ "$1" == "15" ]; then echo "Starting server for PSQL 15" PSQL15=@PSQL15_BINDIR@ @@ -63,6 +63,15 @@ pgsodium.getkey_script = '$PGSODIUM_GETKEY_SCRIPT'" \ -e "\$a\\ session_preload_libraries = 'supautils'" \ "$PSQL_CONF_FILE" > "$DATDIR/postgresql.conf" + +remove_config_items() { + if [ "$1" == "orioledb-16" ]; then + # Remove items from postgresql.conf + sed -i 's/ timescaledb,//g;' "$DATDIR/postgresql.conf" + sed -i 's/ timescaledb,//g; s/ vector,//g; s/ plv8,//g; s/ postgis,//g; s/ pgrouting,//g' "$DATDIR/supautils.conf" + fi +} +remove_config_items "$1" if [ "$CURRENT_SYSTEM" = "aarch64-darwin" ]; then echo "NOTE: using aarch64-darwin system" sed -i '' 's/ pg_net,//g' "$DATDIR/postgresql.conf"