Skip to content

Commit 34a7e8e

Browse files
authored
feat: filter timescaledb to only be included on v15 (#1321)
* feat: filter timescaledb to only be included on v15 * chore: shuffle a bit to match what is needed for various versions * chore: small fixes on sb wrappers and plv8 to merge in all needed install function
1 parent 8910ea0 commit 34a7e8e

File tree

3 files changed

+42
-21
lines changed

3 files changed

+42
-21
lines changed

flake.nix

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
ourExtensions = [
133133
./nix/ext/rum.nix
134134
./nix/ext/timescaledb.nix
135-
./nix/ext/timescaledb-2.9.1.nix
136135
./nix/ext/pgroonga.nix
137136
./nix/ext/index_advisor.nix
138137
./nix/ext/wal2json.nix
@@ -214,9 +213,15 @@
214213
in map (path: pkgs.callPackage path { inherit postgresql; }) orioledbExtension;
215214

216215
makeOurPostgresPkgs = version:
217-
let postgresql = getPostgresqlPackage version;
218-
in map (path: pkgs.callPackage path { inherit postgresql; }) ourExtensions;
219-
216+
let
217+
postgresql = getPostgresqlPackage version;
218+
extensions = if version == "15"
219+
then ourExtensions ++ [
220+
./nix/ext/timescaledb-2.9.1.nix
221+
]
222+
else ourExtensions;
223+
in
224+
map (path: pkgs.callPackage path { inherit postgresql; }) extensions;
220225
# Create an attrset that contains all the extensions included in a server for the orioledb version of postgresql + extension.
221226
makeOurOrioleDbPostgresPkgsSet = version: patchedPostgres:
222227
(builtins.listToAttrs (map

nix/ext/plv8.nix

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,43 @@ stdenv.mkDerivation (finalAttrs: {
9797
''}
9898
'';
9999

100-
postInstall = ''
100+
postInstall = ''
101101
# Move the redirected to proper directory.
102102
# There appear to be no references to the install directories
103103
# so changing them does not cause issues.
104104
mv "$out/nix/store"/*/* "$out"
105105
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"
106-
mv "$out/lib/plv8-${finalAttrs.version}.so" "$out/lib/plv8.so"
107-
ln -s "$out/lib/plv8.so" "$out/lib/plv8-${finalAttrs.version}.so"
108-
sed -i 's|module_pathname = '"'"'$libdir/plv8-[0-9.]*'"'"'|module_pathname = '"'"'$libdir/plv8'"'"'|' "$out/share/postgresql/extension/plv8.control"
109-
sed -i 's|module_pathname = '"'"'$libdir/plv8-[0-9.]*'"'"'|module_pathname = '"'"'$libdir/plv8'"'"'|' "$out/share/postgresql/extension/plcoffee.control"
110-
sed -i 's|module_pathname = '"'"'$libdir/plv8-[0-9.]*'"'"'|module_pathname = '"'"'$libdir/plv8'"'"'|' "$out/share/postgresql/extension/plls.control"
111-
${lib.optionalString stdenv.isDarwin ''
112-
install_name_tool -add_rpath "${v8}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
113-
install_name_tool -add_rpath "${postgresql}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
114-
install_name_tool -add_rpath "${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
115-
install_name_tool -change @rpath/libv8_monolith.dylib ${v8}/lib/libv8_monolith.dylib $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
116-
''}
117106
118-
${lib.optionalString (!stdenv.isDarwin) ''
119-
${patchelf}/bin/patchelf --set-rpath "${v8}/lib:${postgresql}/lib:${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
120-
''}
107+
# Handle different PostgreSQL versions
108+
if [ "${lib.versions.major postgresql.version}" = "15" ]; then
109+
mv "$out/lib/plv8-${finalAttrs.version}.so" "$out/lib/plv8.so"
110+
ln -s "$out/lib/plv8.so" "$out/lib/plv8-${finalAttrs.version}.so"
111+
sed -i 's|module_pathname = '"'"'$libdir/plv8-[0-9.]*'"'"'|module_pathname = '"'"'$libdir/plv8'"'"'|' "$out/share/postgresql/extension/plv8.control"
112+
sed -i 's|module_pathname = '"'"'$libdir/plv8-[0-9.]*'"'"'|module_pathname = '"'"'$libdir/plv8'"'"'|' "$out/share/postgresql/extension/plcoffee.control"
113+
sed -i 's|module_pathname = '"'"'$libdir/plv8-[0-9.]*'"'"'|module_pathname = '"'"'$libdir/plv8'"'"'|' "$out/share/postgresql/extension/plls.control"
114+
115+
${lib.optionalString stdenv.isDarwin ''
116+
install_name_tool -add_rpath "${v8}/lib" $out/lib/plv8.so
117+
install_name_tool -add_rpath "${postgresql}/lib" $out/lib/plv8.so
118+
install_name_tool -add_rpath "${stdenv.cc.cc.lib}/lib" $out/lib/plv8.so
119+
install_name_tool -change @rpath/libv8_monolith.dylib ${v8}/lib/libv8_monolith.dylib $out/lib/plv8.so
120+
''}
121+
122+
${lib.optionalString (!stdenv.isDarwin) ''
123+
${patchelf}/bin/patchelf --set-rpath "${v8}/lib:${postgresql}/lib:${stdenv.cc.cc.lib}/lib" $out/lib/plv8.so
124+
''}
125+
else
126+
${lib.optionalString stdenv.isDarwin ''
127+
install_name_tool -add_rpath "${v8}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
128+
install_name_tool -add_rpath "${postgresql}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
129+
install_name_tool -add_rpath "${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
130+
install_name_tool -change @rpath/libv8_monolith.dylib ${v8}/lib/libv8_monolith.dylib $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
131+
''}
132+
133+
${lib.optionalString (!stdenv.isDarwin) ''
134+
${patchelf}/bin/patchelf --set-rpath "${v8}/lib:${postgresql}/lib:${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
135+
''}
136+
fi
121137
'';
122138

123139
meta = with lib; {

nix/ext/wrappers/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ buildPgrxExtension_0_12_6 rec {
103103
else
104104
echo "Warning: $main_sql_file not found"
105105
fi
106-
mv $out/lib/wrappers-${version}.so $out/lib/wrappers.so
107-
ln -s $out/lib/wrappers.so $out/lib/wrappers-${version}.so
106+
mv $out/lib/wrappers-${version}${postgresql.dlSuffix} $out/lib/wrappers${postgresql.dlSuffix}
107+
ln -s $out/lib/wrappers${postgresql.dlSuffix} $out/lib/wrappers-${version}${postgresql.dlSuffix}
108108
109109
echo "Creating wrappers.so symlinks to support pg_upgrade..."
110110
if [ -f "$out/lib/wrappers.so" ]; then

0 commit comments

Comments
 (0)