1{ lib
2, fetchFromGitHub
3, fetchpatch
4, buildPgxExtension
5, postgresql
6, stdenv
7, nixosTests
8}:
9
10buildPgxExtension rec {
11 inherit postgresql;
12
13 pname = "promscale_extension";
14 version = "0.8.0";
15
16 src = fetchFromGitHub {
17 owner = "timescale";
18 repo = "promscale_extension";
19 rev = version;
20 sha256 = "sha256-vyEfQMGguHrHYdBEEmbev29L2uCa/4xL9DpGIniUwfI=";
21 };
22
23 cargoSha256 = "sha256-VK9DObkg4trcGUXxxISCd0zqU3vc1Qt6NxqpgKIARCQ=";
24
25 cargoPatches = [
26 # there is a duplicate definition in the lock file which fails to build with buildRustPackage
27 (fetchpatch {
28 name = "cargo-vendor.patch";
29 url = "https://github.com/timescale/promscale_extension/commit/3048bd959430e9abc2c1d5c772ab6b4fc1dc6a95.patch";
30 hash = "sha256-xTk4Ml8GN06QlJdrvAdVK21r30ZR/S83y5A5jJPdOw4=";
31 })
32 ];
33
34 preBuild = ''
35 patchShebangs create-upgrade-symlinks.sh extract-extension-version.sh
36 ## Hack to boostrap the build because some pgx commands require this file. It gets re-generated later.
37 cp templates/promscale.control ./promscale.control
38 '';
39 postInstall = ''
40 ln -s $out/lib/promscale-${version}.so $out/lib/promscale.so
41 '';
42 passthru.tests = {
43 promscale = nixosTests.promscale;
44 };
45
46 # tests take really long
47 doCheck = false;
48
49 meta = with lib; {
50 description = "Promscale is an open source observability backend for metrics and traces powered by SQL";
51 homepage = "https://github.com/timescale/promscale_extension";
52 maintainers = with maintainers; [ anpin ];
53 platforms = postgresql.meta.platforms;
54 license = licenses.unfree;
55
56 # as it needs to be used with timescaledb, simply use the condition from there
57 broken = versionOlder postgresql.version "12"
58 || versionAtLeast postgresql.version "15";
59 };
60}