Skip to content

Commit 5a4d54b

Browse files
chatchclaude
andcommitted
Add TimescaleDB Toolkit extension support for PostgreSQL 17
- Added timescaledb-toolkit.nix to build from prebuilt Ubuntu package - Included extension in PostgreSQL 17 builds - Added pgTAP test for extension loading - Excluded from OrioleDB builds to maintain compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ccc7c4b commit 5a4d54b

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
./nix/ext/rum.nix
132132
./nix/ext/timescaledb.nix
133133
./nix/ext/timescaledb-2.9.1.nix
134+
./nix/ext/timescaledb-toolkit.nix
134135
./nix/ext/pgroonga.nix
135136
./nix/ext/index_advisor.nix
136137
./nix/ext/wal2json.nix
@@ -169,6 +170,7 @@
169170
x:
170171
x != ./nix/ext/timescaledb.nix &&
171172
x != ./nix/ext/timescaledb-2.9.1.nix &&
173+
x != ./nix/ext/timescaledb-toolkit.nix &&
172174
x != ./nix/ext/plv8.nix
173175
) ourExtensions;
174176

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
BEGIN;
2+
create extension if not exists timescaledb_toolkit with schema "extensions";
3+
ROLLBACK;

nix/ext/timescaledb-toolkit.nix

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{ lib, stdenv, fetchurl, postgresql, dpkg, patchelf, glibc }:
2+
3+
stdenv.mkDerivation rec {
4+
pname = "timescaledb-toolkit";
5+
version = "1.21.0";
6+
7+
# Use the official TimescaleDB toolkit package for PostgreSQL 17
8+
src = fetchurl {
9+
url = "https://packagecloud.io/timescale/timescaledb/packages/ubuntu/jammy/timescaledb-toolkit-postgresql-17_${version}~ubuntu22.04_amd64.deb/download";
10+
sha256 = "12l8pngxa6vw7vkgngyyyx5gk151iay6js2smi8wkrwwscx80hjd";
11+
};
12+
13+
nativeBuildInputs = [ dpkg patchelf ];
14+
buildInputs = [ postgresql glibc ];
15+
16+
unpackPhase = ''
17+
runHook preUnpack
18+
dpkg-deb -x $src .
19+
runHook postUnpack
20+
'';
21+
22+
installPhase = ''
23+
runHook preInstall
24+
25+
# Create output directories
26+
mkdir -p $out/lib
27+
mkdir -p $out/share/postgresql/extension
28+
29+
# Copy the shared library
30+
if [ -f usr/lib/postgresql/17/lib/timescaledb_toolkit-*.so ]; then
31+
cp usr/lib/postgresql/17/lib/timescaledb_toolkit-*.so $out/lib/
32+
fi
33+
34+
# Copy extension files
35+
if [ -d usr/share/postgresql/17/extension ]; then
36+
cp -r usr/share/postgresql/17/extension/* $out/share/postgresql/extension/
37+
fi
38+
39+
runHook postInstall
40+
'';
41+
42+
postFixup = ''
43+
# Fix the RPATH for the shared library
44+
for lib in $out/lib/*.so; do
45+
if [ -f "$lib" ]; then
46+
patchelf --set-rpath "${lib.makeLibraryPath [ postgresql glibc ]}" "$lib" || true
47+
fi
48+
done
49+
'' + lib.optionalString (!stdenv.isDarwin) ''
50+
# Additional fixup for Linux
51+
for lib in $out/lib/*.so; do
52+
if [ -f "$lib" ]; then
53+
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$lib" 2>/dev/null || true
54+
fi
55+
done
56+
'';
57+
58+
meta = with lib; {
59+
description = "Extension for more hyperfunctions, fully compatible with TimescaleDB and PostgreSQL";
60+
homepage = "https://github.com/timescale/timescaledb-toolkit";
61+
license = licenses.asl20;
62+
platforms = postgresql.meta.platforms;
63+
maintainers = with maintainers; [ ];
64+
};
65+
}

0 commit comments

Comments
 (0)