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