Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ common-nix.vars.pkr.hcl

# pre-commit config is managed in nix
.pre-commit-config.yaml
nixos.qcow2
nixos.qcow2
18 changes: 18 additions & 0 deletions Dockerfile-15
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ RUN nix profile install .#wal-g-3 && \

RUN nix store gc

WORKDIR /
####################
# setup-groonga
####################
FROM base as groonga

WORKDIR /nixpg

RUN nix profile install .#supabase-groonga && \
mkdir -p /tmp/groonga-plugins && \
cp -r /nix/var/nix/profiles/default/lib/groonga/plugins /tmp/groonga-plugins/

RUN nix store gc

WORKDIR /
# ####################
# # Download gosu for easy step-down from root
Expand Down Expand Up @@ -153,6 +167,7 @@ FROM gosu as production
RUN id postgres || (echo "postgres user does not exist" && exit 1)
# # Setup extensions
COPY --from=walg /tmp/wal-g /usr/local/bin/
COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins

# # Initialise configs
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
Expand Down Expand Up @@ -216,4 +231,7 @@ ENV LOCALE_ARCHIVE /usr/lib/locale/locale-archive
RUN mkdir -p /usr/share/postgresql/extension/ && \
ln -s /usr/lib/postgresql/bin/pgsodium_getkey.sh /usr/share/postgresql/extension/pgsodium_getkey && \
chmod +x /usr/lib/postgresql/bin/pgsodium_getkey.sh

ENV GRN_PLUGINS_DIR=/usr/lib/groonga/plugins

CMD ["postgres", "-D", "/etc/postgresql"]
18 changes: 18 additions & 0 deletions Dockerfile-17
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ RUN nix profile install .#wal-g-3 && \

RUN nix store gc

WORKDIR /
####################
# setup-groonga
####################
FROM base as groonga

WORKDIR /nixpg

RUN nix profile install .#supabase-groonga && \
mkdir -p /tmp/groonga-plugins && \
cp -r /nix/var/nix/profiles/default/lib/groonga/plugins /tmp/groonga-plugins/

RUN nix store gc

WORKDIR /
# ####################
# # Download gosu for easy step-down from root
Expand Down Expand Up @@ -157,6 +171,7 @@ FROM gosu as production
RUN id postgres || (echo "postgres user does not exist" && exit 1)
# # Setup extensions
COPY --from=walg /tmp/wal-g /usr/local/bin/
COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins

# # Initialise configs
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
Expand Down Expand Up @@ -229,4 +244,7 @@ ENV LOCALE_ARCHIVE /usr/lib/locale/locale-archive
RUN mkdir -p /usr/share/postgresql/extension/ && \
ln -s /usr/lib/postgresql/bin/pgsodium_getkey.sh /usr/share/postgresql/extension/pgsodium_getkey && \
chmod +x /usr/lib/postgresql/bin/pgsodium_getkey.sh

ENV GRN_PLUGINS_DIR=/usr/lib/groonga/plugins

CMD ["postgres", "-D", "/etc/postgresql"]
17 changes: 17 additions & 0 deletions Dockerfile-orioledb-17
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ RUN nix profile install .#wal-g-3 && \

RUN nix store gc

WORKDIR /
####################
# setup-groonga
####################
FROM base as groonga

WORKDIR /nixpg

RUN nix profile install .#supabase-groonga && \
mkdir -p /tmp/groonga-plugins && \
cp -r /nix/var/nix/profiles/default/lib/groonga/plugins /tmp/groonga-plugins/

RUN nix store gc

WORKDIR /
# ####################
# # Download gosu for easy step-down from root
Expand Down Expand Up @@ -157,6 +171,7 @@ FROM gosu as production
RUN id postgres || (echo "postgres user does not exist" && exit 1)
# # Setup extensions
COPY --from=walg /tmp/wal-g /usr/local/bin/
COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins

# # Initialise configs
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
Expand Down Expand Up @@ -235,4 +250,6 @@ RUN mkdir -p /usr/share/postgresql/extension/ && \
ln -s /usr/lib/postgresql/bin/pgsodium_getkey.sh /usr/share/postgresql/extension/pgsodium_getkey && \
chmod +x /usr/lib/postgresql/bin/pgsodium_getkey.sh

ENV GRN_PLUGINS_DIR=/usr/lib/groonga/plugins

CMD ["postgres", "-D", "/etc/postgresql"]
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ begin
physical backups everywhere
*/
-- Detach and delete the official function
alter extension pgmq drop function pgmq.drop_queue;
drop function pgmq.drop_queue;
alter extension pgmq drop function pgmq.drop_queue(TEXT);
drop function pgmq.drop_queue(TEXT);

-- Create and reattach the patched function
CREATE FUNCTION pgmq.drop_queue(queue_name TEXT)
Expand Down Expand Up @@ -134,7 +134,7 @@ BEGIN
END;
$func$ LANGUAGE plpgsql;

alter extension pgmq add function pgmq.drop_queue;
alter extension pgmq add function pgmq.drop_queue(TEXT);


update pg_extension set extowner = 'postgres'::regrole where extname = 'pgmq';
Expand Down
6 changes: 3 additions & 3 deletions ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ postgres_major:

# Full version strings for each major version
postgres_release:
postgresorioledb-17: 17.5.1.036-orioledb
postgres17: 17.6.1.015
postgres15: 15.14.1.015
postgresorioledb-17: "17.5.1.061-orioledb"
postgres17: "17.6.1.040"
postgres15: "15.14.1.040"

# Non Postgres Extensions
pgbouncer_release: 1.19.0
Expand Down
1 change: 0 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
nix/checks.nix
nix/config.nix
nix/devShells.nix
nix/ext
nix/fmt.nix
nix/hooks.nix
nix/nixpkgs.nix
Expand Down
3 changes: 2 additions & 1 deletion nix/cargo-pgrx/buildPgrxExtension.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
stdenv,
darwin,
writeShellScriptBin,
defaultBindgenHook,
}:

# The idea behind: Use it mostly like rustPlatform.buildRustPackage and so
Expand All @@ -56,7 +57,7 @@
# enable override to generate bindings using bindgenHook.
# Some older versions of cargo-pgrx use a bindgenHook that is not compatible with the
# current clang version present in stdenv
bindgenHook ? rustPlatform.bindgenHook,
bindgenHook ? defaultBindgenHook,
# cargo-pgrx calls rustfmt on generated bindings, this is not strictly necessary, so we avoid the
# dependency here. Set to false and provide rustfmt in nativeBuildInputs, if you need it, e.g.
# if you include the generated code in the output via postInstall.
Expand Down
5 changes: 5 additions & 0 deletions nix/cargo-pgrx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ let
};
in
{
cargo-pgrx_0_10_2 = mkCargoPgrx {
version = "0.10.2";
hash = "sha256-FqjfbJmSy5UCpPPPk4bkEyvQCnaH9zYtkI7txgIn+ls=";
cargoHash = "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI=";
};
cargo-pgrx_0_11_3 = mkCargoPgrx {
version = "0.11.3";
hash = "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU=";
Expand Down
21 changes: 21 additions & 0 deletions nix/cargo-pgrx/mkPgrxExtension.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
pgrxVersion,
makeRustPlatform,
rust-bin,
system,
}:
let
inherit ((callPackage ./default.nix { inherit rustVersion; })) mkCargoPgrx;
Expand Down Expand Up @@ -31,8 +32,28 @@ let
inherit (mapping) hash cargoHash;
version = pgrxVersion;
};

bindgenHook =
# Fix bindgen error on aarch64-linux for versions using pgrx with bindgen 0.68.1
# This affects pgrx 0.6.1 through 0.11.2 which have issues with ARM NEON vector ABI
if (builtins.compareVersions "0.11.3" pgrxVersion > 0) then
let
nixos2211 = (
import (builtins.fetchTarball {
url = "https://channels.nixos.org/nixos-22.11/nixexprs.tar.xz";
sha256 = "1j7h75a9hwkkm97jicky5rhvzkdwxsv5v46473rl6agvq2sj97y1";
}) { inherit system; }
);
in
rustPlatform.bindgenHook.overrideAttrs {
libclang = nixos2211.clang.cc.lib;
clang = nixos2211.clang;
}
else
rustPlatform.bindgenHook;
in
callPackage ./buildPgrxExtension.nix {
inherit rustPlatform;
inherit cargo-pgrx;
defaultBindgenHook = bindgenHook;
}
12 changes: 12 additions & 0 deletions nix/cargo-pgrx/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"rust": {
"1.70.0": {
"cargoHash": "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI="
},
"1.76.0": {
"cargoHash": "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI="
}
}
},
Expand Down Expand Up @@ -107,5 +110,14 @@
"cargoHash": "sha256-TODO-NEEDS-PROPER-HASH"
}
}
},
"0.16.0": {
"hash": "sha256-emNR7fXNVD9sY/Mdno7mwpH6l/7AD28cBUsFRn9je50=",
"rust": {
"1.87.0": {
"cargoHash": "sha256-pK6OxRNubcWhohLvIJIliRtaHSIQOhQp7Q9brPygZYA="
}
}
}

}
54 changes: 28 additions & 26 deletions nix/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
psql_15 = self'.packages."psql_15/bin";
psql_17 = self'.packages."psql_17/bin";
psql_orioledb-17 = self'.packages."psql_orioledb-17/bin";
pgroonga = self'.packages."psql_15/exts/pgroonga";
inherit (self.supabase) defaults;
};
in
Expand Down Expand Up @@ -68,9 +67,36 @@
'';
};

# Get the major version for filtering
majorVersion =
let
version = builtins.trace "pgpkg.version is: ${pgpkg.version}" pgpkg.version;
isOrioledbMatch = builtins.match "^17_[0-9]+$" version != null;
isSeventeenMatch = builtins.match "^17[.][0-9]+$" version != null;
result =
if isOrioledbMatch then
"orioledb-17"
else if isSeventeenMatch then
"17"
else
"15";
in
builtins.trace "Major version result: ${result}" result;

# Select the appropriate pgroonga package for this PostgreSQL version
pgroonga = self'.packages."psql_${majorVersion}/exts/pgroonga-all";

pgPort =
if (majorVersion == "17") then
"5535"
else if (majorVersion == "15") then
"5536"
else
"5537";

# Use the shared setup but with a test-specific name
start-postgres-server-bin = pkgs-lib.makePostgresDevSetup {
inherit pkgs;
inherit pkgs pgroonga;
name = "start-postgres-server-test";
extraSubstitutions = {
PGSODIUM_GETKEY = "${getkey-script}/bin/pgsodium-getkey";
Expand Down Expand Up @@ -116,33 +142,9 @@
in
pkgs.lib.filterAttrs (name: _: isValidFile name) files;

# Get the major version for filtering
majorVersion =
let
version = builtins.trace "pgpkg.version is: ${pgpkg.version}" pgpkg.version;
isOrioledbMatch = builtins.match "^17_[0-9]+$" version != null;
isSeventeenMatch = builtins.match "^17[.][0-9]+$" version != null;
result =
if isOrioledbMatch then
"orioledb-17"
else if isSeventeenMatch then
"17"
else
"15";
in
builtins.trace "Major version result: ${result}" result; # Trace the result # For "15.8"

# Filter SQL test files
filteredSqlTests = filterTestFiles majorVersion ./tests/sql;

pgPort =
if (majorVersion == "17") then
"5535"
else if (majorVersion == "15") then
"5536"
else
"5537";

# Convert filtered tests to a sorted list of basenames (without extension)
testList = pkgs.lib.mapAttrsToList (
name: _: builtins.substring 0 (pkgs.lib.stringLength name - 4) name
Expand Down
11 changes: 0 additions & 11 deletions nix/ext/default.nix

This file was deleted.

26 changes: 0 additions & 26 deletions nix/ext/pg_graphql/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
postgresql,
rust-bin,
rsync,
system,
rustPlatform,
}:

let
Expand Down Expand Up @@ -104,30 +102,6 @@ let
inherit (postgresql.meta) platforms;
};
}
//
lib.optionalAttrs
(
# Fix bindgen error on aarch64-linux for versions using pgrx with bindgen 0.68.1
# This affects pgrx 0.6.1 through 0.11.2 which have issues with ARM NEON vector ABI
# We apply the fix to all versions up to 1.5.1 (last version before 1.5.4 which uses 0.11.2)
builtins.compareVersions "1.5.4" version > 0
)
{
# Fix bindgen error on aarch64-linux by using an older version of clang
bindgenHook =
let
nixos2211 = (
import (builtins.fetchTarball {
url = "https://channels.nixos.org/nixos-22.11/nixexprs.tar.xz";
sha256 = "1j7h75a9hwkkm97jicky5rhvzkdwxsv5v46473rl6agvq2sj97y1";
}) { inherit system; }
);
in
rustPlatform.bindgenHook.overrideAttrs {
libclang = nixos2211.clang.cc.lib;
clang = nixos2211.clang;
};
}
// lib.optionalAttrs (builtins.compareVersions "1.2.0" version >= 0) {
# Add missing Cargo.lock
patches = [ ./0001-Add-missing-Cargo.lock-${version}.patch ];
Expand Down
Loading