Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 106 lines 3.1 kB view raw
1{ 2 cmake, 3 fetchFromGitHub, 4 lib, 5 libkrb5, 6 openssl, 7 postgresql, 8 postgresqlBuildExtension, 9 postgresqlTestExtension, 10 11 enableUnfree ? true, 12}: 13 14postgresqlBuildExtension (finalAttrs: { 15 pname = "timescaledb${lib.optionalString (!enableUnfree) "-apache"}"; 16 version = "2.21.0"; 17 18 src = fetchFromGitHub { 19 owner = "timescale"; 20 repo = "timescaledb"; 21 tag = finalAttrs.version; 22 hash = "sha256-t3BPy1rmV3f/OFDHqiRh1E9tNH7dc1LCTktvkSSZLro="; 23 }; 24 25 nativeBuildInputs = [ cmake ]; 26 buildInputs = [ 27 openssl 28 libkrb5 29 ]; 30 31 cmakeFlags = [ 32 (lib.cmakeBool "SEND_TELEMETRY_DEFAULT" false) 33 (lib.cmakeBool "REGRESS_CHECKS" false) 34 (lib.cmakeBool "TAP_CHECKS" false) 35 (lib.cmakeBool "APACHE_ONLY" (!enableUnfree)) 36 ]; 37 38 # Fix the install phase which tries to install into the pgsql extension dir, 39 # and cannot be manually overridden. This is rather fragile but works OK. 40 postPatch = '' 41 for x in CMakeLists.txt sql/CMakeLists.txt; do 42 substituteInPlace "$x" \ 43 --replace-fail 'DESTINATION "''${PG_SHAREDIR}/extension"' "DESTINATION \"$out/share/postgresql/extension\"" 44 done 45 46 for x in src/CMakeLists.txt src/loader/CMakeLists.txt tsl/src/CMakeLists.txt; do 47 substituteInPlace "$x" \ 48 --replace-fail 'DESTINATION ''${PG_PKGLIBDIR}' "DESTINATION \"$out/lib\"" 49 done 50 ''; 51 52 passthru.tests.extension = postgresqlTestExtension { 53 inherit (finalAttrs) finalPackage; 54 withPackages = [ "timescaledb_toolkit" ]; 55 postgresqlExtraSettings = '' 56 shared_preload_libraries='timescaledb' 57 ''; 58 sql = '' 59 CREATE EXTENSION timescaledb; 60 CREATE EXTENSION timescaledb_toolkit; 61 62 CREATE TABLE sth ( 63 time TIMESTAMPTZ NOT NULL, 64 value DOUBLE PRECISION 65 ); 66 67 SELECT create_hypertable('sth', 'time'); 68 69 INSERT INTO sth (time, value) VALUES 70 ('2003-04-12 04:05:06 America/New_York', 1.0), 71 ('2003-04-12 04:05:07 America/New_York', 2.0), 72 ('2003-04-12 04:05:08 America/New_York', 3.0), 73 ('2003-04-12 04:05:09 America/New_York', 4.0), 74 ('2003-04-12 04:05:10 America/New_York', 5.0) 75 ; 76 77 WITH t AS ( 78 SELECT 79 time_bucket('1 day'::interval, time) AS dt, 80 stats_agg(value) AS stats 81 FROM sth 82 GROUP BY time_bucket('1 day'::interval, time) 83 ) 84 SELECT 85 average(stats) 86 FROM t; 87 ''; 88 asserts = [ 89 { 90 query = "SELECT count(*) FROM sth"; 91 expected = "5"; 92 description = "hypertable can be queried successfully."; 93 } 94 ]; 95 }; 96 97 meta = { 98 description = "Scales PostgreSQL for time-series data via automatic partitioning across time and space"; 99 homepage = "https://www.timescale.com/"; 100 changelog = "https://github.com/timescale/timescaledb/blob/${finalAttrs.version}/CHANGELOG.md"; 101 maintainers = with lib.maintainers; [ kirillrdy ]; 102 platforms = postgresql.meta.platforms; 103 license = with lib.licenses; if enableUnfree then tsl else asl20; 104 broken = lib.versionOlder postgresql.version "15"; 105 }; 106})