Skip to content
Merged
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
20 changes: 8 additions & 12 deletions nix/ext/wrappers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,20 @@
, jq
}:

let
gitTags = builtins.fromJSON (builtins.readFile (builtins.fetchurl {
url = "https://api.github.com/repos/supabase/wrappers/tags";
sha256 = "0pvavn0f8wnaszq4bmvjkadm6xbvf91rbhcmmgjasqajb69vskv9"; # Replace with actual hash
}));
in
buildPgrxExtension_0_11_3 rec {
pname = "supabase-wrappers";
version = "0.4.1";
# update the following array when the wrappers version is updated
# required to ensure that extensions update scripts from previous versions are generated
previousVersions = ["0.4.0" "0.3.1" "0.3.0" "0.2.0" "0.1.19" "0.1.18" "0.1.17" "0.1.16" "0.1.15" "0.1.14" "0.1.12" "0.1.11" "0.1.10" "0.1.9" "0.1.8" "0.1.7" "0.1.6" "0.1.5" "0.1.4" "0.1.1" "0.1.0"];
inherit postgresql;
src = fetchFromGitHub {
owner = "supabase";
repo = "wrappers";
rev = "v${version}";
hash = "sha256-AU9Y43qEMcIBVBThu+Aor1HCtfFIg+CdkzK9IxVdkzM=";
};
nativeBuildInputs = [ pkg-config cargo jq ];
nativeBuildInputs = [ pkg-config cargo ];
buildInputs = [ openssl ] ++ lib.optionals (stdenv.isDarwin) [
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Security
Expand Down Expand Up @@ -62,7 +59,7 @@ buildPgrxExtension_0_11_3 rec {

preBuild = ''
echo "Processing git tags..."
echo '${builtins.toJSON gitTags}' | ${jq}/bin/jq -r '.[].name' | sort -rV > git_tags.txt
echo '${builtins.concatStringsSep "," previousVersions}' | sed 's/,/\n/g' > git_tags.txt
'';

postInstall = ''
Expand All @@ -71,10 +68,9 @@ buildPgrxExtension_0_11_3 rec {
sql_file="$out/share/postgresql/extension/wrappers--$current_version.sql"

if [ -f "$sql_file" ]; then
while read -r tag; do
tag_version=$(echo "$tag" | sed 's/^v//')
if [ "$(printf '%s\n' "$tag_version" "$current_version" | sort -V | head -n1)" = "$tag_version" ] && [ "$tag_version" != "$current_version" ]; then
new_file="$out/share/postgresql/extension/wrappers--$tag_version--$current_version.sql"
while read -r previous_version; do
if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
new_file="$out/share/postgresql/extension/wrappers--$previous_version--$current_version.sql"
echo "Creating $new_file"
cp "$sql_file" "$new_file"
fi
Expand Down
Loading