7
7
, buildPgrxExtension_0_11_3
8
8
, cargo
9
9
, darwin
10
+ , jq
10
11
} :
11
12
13
+ let
14
+ gitTags = builtins . fromJSON ( builtins . readFile ( builtins . fetchurl {
15
+ url = "https://api.github.com/repos/supabase/wrappers/tags" ;
16
+ sha256 = "0am40yspir70wp8pik1c7qmfvbby3nyxza115pi9klp6fyv2s93j" ; # Replace with actual hash
17
+ } ) ) ;
18
+ in
12
19
buildPgrxExtension_0_11_3 rec {
13
20
pname = "supabase-wrappers" ;
14
21
version = "0.4.1" ;
15
22
inherit postgresql ;
16
-
17
23
src = fetchFromGitHub {
18
24
owner = "supabase" ;
19
25
repo = "wrappers" ;
20
26
rev = "v${ version } " ;
21
27
hash = "sha256-AU9Y43qEMcIBVBThu+Aor1HCtfFIg+CdkzK9IxVdkzM=" ;
22
28
} ;
23
-
24
- nativeBuildInputs = [ pkg-config cargo ] ;
25
-
26
- buildInputs = [ openssl ] ++ lib . optionals ( stdenv . isDarwin ) [
29
+ nativeBuildInputs = [ pkg-config cargo jq ] ;
30
+ buildInputs = [ openssl ] ++ lib . optionals ( stdenv . isDarwin ) [
27
31
darwin . apple_sdk . frameworks . CoreFoundation
28
32
darwin . apple_sdk . frameworks . Security
29
33
darwin . apple_sdk . frameworks . SystemConfiguration
30
34
] ;
31
-
32
- # Needed to get openssl-sys to use pkg-config.
33
35
OPENSSL_NO_VENDOR = 1 ;
34
36
35
37
CARGO = "${ cargo } /bin/cargo" ;
36
-
37
38
cargoLock = {
38
- #TODO when we move to newer versions this lockfile will need to be sourced
39
- # from ${src}/Cargo.lock
40
39
lockFile = "${ src } /Cargo.lock" ;
41
40
outputHashes = {
42
41
"clickhouse-rs-1.0.0-alpha.1" = "sha256-0zmoUo/GLyCKDLkpBsnLAyGs1xz6cubJhn+eVqMEMaw=" ;
43
42
} ;
44
43
} ;
45
44
postPatch = "cp ${ cargoLock . lockFile } Cargo.lock" ;
46
-
47
45
buildAndTestSubdir = "wrappers" ;
48
46
buildFeatures = [
49
47
"helloworld_fdw"
@@ -60,17 +58,38 @@ buildPgrxExtension_0_11_3 rec {
60
58
"cognito_fdw"
61
59
"wasm_fdw"
62
60
] ;
63
-
64
- # FIXME (aseipp): disable the tests since they try to install .control
65
- # files into the wrong spot, aside from that the one main test seems
66
- # to work, though
67
61
doCheck = false ;
68
62
63
+ preBuild = ''
64
+ echo "Processing git tags..."
65
+ echo '${ builtins . toJSON gitTags } ' | ${ jq } /bin/jq -r '.[].name' | sort -rV > git_tags.txt
66
+ '' ;
67
+
68
+ postInstall = ''
69
+ echo "Creating SQL files for previous versions..."
70
+ current_version="${ version } "
71
+ sql_file="$out/share/postgresql/extension/wrappers--$current_version.sql"
72
+
73
+ if [ -f "$sql_file" ]; then
74
+ while read -r tag; do
75
+ tag_version=$(echo "$tag" | sed 's/^v//')
76
+ if [ "$(printf '%s\n' "$tag_version" "$current_version" | sort -V | head -n1)" = "$tag_version" ] && [ "$tag_version" != "$current_version" ]; then
77
+ new_file="$out/share/postgresql/extension/wrappers--$tag_version--$current_version.sql"
78
+ echo "Creating $new_file"
79
+ cp "$sql_file" "$new_file"
80
+ fi
81
+ done < git_tags.txt
82
+ else
83
+ echo "Warning: $sql_file not found"
84
+ fi
85
+ rm git_tags.txt
86
+ '' ;
87
+
69
88
meta = with lib ; {
70
89
description = "Various Foreign Data Wrappers (FDWs) for PostreSQL" ;
71
90
homepage = "https://github.com/supabase/wrappers" ;
72
91
maintainers = with maintainers ; [ samrose ] ;
73
92
platforms = postgresql . meta . platforms ;
74
93
license = licenses . postgresql ;
75
94
} ;
76
- }
95
+ }
0 commit comments