|
79 | 79 |
|
80 | 80 | preCheck='' |
81 | 81 | export PGRX_HOME="$(mktemp -d)" |
82 | | - export PG_VERSION="${lib.versions.majorpostgresql.version}" |
| 82 | + export PG_VERSION="${pgVersion}" |
83 | 83 | export NIX_PGLIBDIR="$PGRX_HOME/$PG_VERSION/lib" |
84 | 84 | export PATH="$PGRX_HOME/$PG_VERSION/bin:$PATH" |
85 | 85 | ${lib.getExersync} --chmod=ugo+w -a${postgresql}/${postgresql.lib}/ "$PGRX_HOME/$PG_VERSION/" |
@@ -119,19 +119,64 @@ let |
119 | 119 | } |
120 | 120 | ); |
121 | 121 | allVersions=(builtins.fromJSON(builtins.readFile../versions.json)).pg_graphql; |
| 122 | +pgVersion=lib.versions.majorpostgresql.version; |
122 | 123 | supportedVersions=lib.filterAttrs( |
123 | | -_:value:builtins.elem(lib.versions.majorpostgresql.version)value.postgresql |
| 124 | +_:value:builtins.elempgVersionvalue.postgresql |
124 | 125 | )allVersions; |
125 | 126 | versions=lib.naturalSort(lib.attrNamessupportedVersions); |
126 | 127 | latestVersion=lib.lastversions; |
127 | 128 | numberOfVersions=builtins.lengthversions; |
128 | 129 | packages=builtins.attrValues( |
129 | 130 | lib.mapAttrs(name:value:buildnamevalue.hashvalue.rustvalue.pgrx)supportedVersions |
130 | 131 | ); |
| 132 | +buildUnsupported= |
| 133 | +# Build SQL-only packages for unsupported versions needed by pg_upgrade. |
| 134 | +# When upgrading PostgreSQL, pg_upgrade requires old extension versions to exist |
| 135 | +# even if they can't compile against the new PostgreSQL version. |
| 136 | +version:hash:_rustVersion:_pgrxVersion: |
| 137 | +stdenv.mkDerivation{ |
| 138 | +inheritpnameversion; |
| 139 | +src=fetchFromGitHub{ |
| 140 | +owner="supabase"; |
| 141 | +repo=pname; |
| 142 | +rev="v${version}"; |
| 143 | +inherithash; |
| 144 | +}; |
| 145 | +phases=["installPhase"]; |
| 146 | +installPhase='' |
| 147 | + mkdir -p $out/share/postgresql/extension |
| 148 | + for file in $src/sql/*.sql; do |
| 149 | + filename=$(basename "$file") |
| 150 | + if [[ "$filename" != "load_sql_config.sql" && "$filename" != "load_sql_context.sql" ]]; then |
| 151 | + cat "$file" |
| 152 | + echo ";" |
| 153 | + fi |
| 154 | + done > $out/share/postgresql/extension/${pname}--${version}.sql |
| 155 | + ''; |
| 156 | +meta=withlib;{ |
| 157 | +description="GraphQL support for PostreSQL"; |
| 158 | +homepage="https://github.com/supabase/${pname}"; |
| 159 | +license=licenses.postgresql; |
| 160 | +inherit(postgresql.meta)platforms; |
| 161 | +}; |
| 162 | +}; |
| 163 | +unsupportedVersions=lib.filterAttrs( |
| 164 | +_:value:!builtins.elempgVersionvalue.postgresql |
| 165 | +)allVersions; |
| 166 | +unsupportedPackages= |
| 167 | +ifpgVersion==15then |
| 168 | +[] |
| 169 | +else |
| 170 | +# Include SQL-only packages for PG15 extension versions incompatible with current PG |
| 171 | +builtins.attrValues( |
| 172 | +lib.mapAttrs( |
| 173 | +name:value:buildUnsupportednamevalue.hashvalue.rustvalue.pgrx |
| 174 | +)unsupportedVersions |
| 175 | +); |
131 | 176 | in |
132 | 177 | buildEnv{ |
133 | 178 | name=pname; |
134 | | -paths=packages; |
| 179 | +paths=packages++unsupportedPackages; |
135 | 180 | pathsToLink=[ |
136 | 181 | "/lib" |
137 | 182 | "/share/postgresql/extension" |
|