8
8
libkrb5 ,
9
9
} :
10
10
11
- stdenv . mkDerivation rec {
12
- pname = "timescaledb-apache" ;
13
- version = "2.16.1" ;
11
+ let
12
+ pname = "timescaledb" ;
13
+ build = version : hash : revision :
14
+ stdenv . mkDerivation rec {
15
+ inherit pname version ;
14
16
15
17
nativeBuildInputs = [ cmake ] ;
16
18
buildInputs = [
@@ -19,12 +21,12 @@ stdenv.mkDerivation rec {
19
21
libkrb5
20
22
] ;
21
23
22
- src = fetchFromGitHub {
23
- owner = "timescale" ;
24
- repo = "timescaledb" ;
25
- rev = version ;
26
- hash = "sha256-sLxWdBmih9mgiO51zLLxn9uwJVYc5JVHJjSWoADoJ+w=" ;
27
- } ;
24
+ src = fetchFromGitHub {
25
+ owner = "timescale" ;
26
+ repo = "timescaledb" ;
27
+ rev = version ;
28
+ inherit hash ;
29
+ } ;
28
30
29
31
cmakeFlags = [
30
32
"-DSEND_TELEMETRY_DEFAULT=OFF"
@@ -33,26 +35,75 @@ stdenv.mkDerivation rec {
33
35
"-DAPACHE_ONLY=1"
34
36
] ++ lib . optionals stdenv . isDarwin [ "-DLINTER=OFF" ] ;
35
37
36
- # Fix the install phase which tries to install into the pgsql extension dir,
37
- # and cannot be manually overridden. This is rather fragile but works OK.
38
- postPatch = ''
39
- for x in CMakeLists.txt sql/CMakeLists.txt; do
40
- substituteInPlace "$x" \
41
- --replace 'DESTINATION "'' ${PG_SHAREDIR}/extension"' "DESTINATION \"$out/share/postgresql/extension\""
42
- done
43
-
44
- for x in src/CMakeLists.txt src/loader/CMakeLists.txt tsl/src/CMakeLists.txt; do
45
- substituteInPlace "$x" \
46
- --replace 'DESTINATION '' ${PG_PKGLIBDIR}' "DESTINATION \"$out/lib\""
47
- done
48
- '' ;
38
+ postPatch = ''
39
+ for x in CMakeLists.txt sql/CMakeLists.txt; do
40
+ if [ -f "$x" ]; then
41
+ substituteInPlace "$x" \
42
+ --replace 'DESTINATION "'' ${PG_SHAREDIR}/extension"' "DESTINATION \"$out/share/postgresql/extension\""
43
+ fi
44
+ done
45
+
46
+ for x in src/CMakeLists.txt src/loader/CMakeLists.txt tsl/src/CMakeLists.txt; do
47
+ if [ -f "$x" ]; then
48
+ substituteInPlace "$x" \
49
+ --replace 'DESTINATION '' ${PG_PKGLIBDIR}' "DESTINATION \"$out/lib\""
50
+ fi
51
+ done
52
+ '' ;
53
+
54
+ postInstall = ''
55
+ if [ -f $out/lib/timescaledb.so ]; then
56
+ mv $out/lib/timescaledb.so $out/lib/timescaledb-${ version } .so
57
+ fi
58
+ if [ -f $out/share/postgresql/extension/timescaledb.control ]; then
59
+ mv $out/share/postgresql/extension/timescaledb.control $out/share/postgresql/extension/timescaledb--${ version } .control
60
+ fi
61
+ '' ;
49
62
50
- meta = with lib ; {
51
- description = "Scales PostgreSQL for time-series data via automatic partitioning across time and space" ;
52
- homepage = "https://www.timescale.com/" ;
53
- changelog = "https://github.com/timescale/timescaledb/blob/${ version } /CHANGELOG.md" ;
54
- platforms = postgresql . meta . platforms ;
55
- license = licenses . asl20 ;
56
- broken = versionOlder postgresql . version "13" ;
63
+ meta = with lib ; {
64
+ description =
65
+ "Scales PostgreSQL for time-series data via automatic partitioning across time and space" ;
66
+ homepage = "https://www.timescale.com/" ;
67
+ changelog =
68
+ "https://github.com/timescale/timescaledb/blob/${ version } /CHANGELOG.md" ;
69
+ license = licenses . postgresql ;
70
+ inherit ( postgresql . meta ) platforms ;
71
+ } ;
72
+ } ;
73
+
74
+ allVersions =
75
+ ( builtins . fromJSON ( builtins . readFile ./versions.json ) ) . timescaledb ;
76
+ supportedVersions = lib . filterAttrs ( _ : value :
77
+ builtins . elem ( lib . versions . major postgresql . version ) value . postgresql )
78
+ allVersions ;
79
+ versions = lib . naturalSort ( lib . attrNames supportedVersions ) ;
80
+ latestVersion = lib . last versions ;
81
+ numberOfVersions = builtins . length versions ;
82
+ packages = builtins . attrValues
83
+ ( lib . mapAttrs ( name : value : build name value . hash ( value . revision or name ) )
84
+ supportedVersions ) ;
85
+ in pkgs . buildEnv {
86
+ name = pname ;
87
+ paths = packages ;
88
+ postBuild = ''
89
+ {
90
+ echo "default_version = '${ latestVersion } '"
91
+ cat $out/share/postgresql/extension/${ pname } --${ latestVersion } .control
92
+ } > $out/share/postgresql/extension/${ pname } .control
93
+ ln -sfn ${ pname } -${ latestVersion } ${ postgresql . dlSuffix } $out/lib/${ pname } ${ postgresql . dlSuffix }
94
+
95
+ # checks
96
+ (set -x
97
+ test "$(ls -A $out/lib/${ pname } *${ postgresql . dlSuffix } | wc -l)" = "${
98
+ toString ( numberOfVersions + 1 )
99
+ } "
100
+ )
101
+ '' ;
102
+ pathsToLink = [ "/lib" "/share/postgresql/extension" ] ;
103
+ passthru = {
104
+ inherit versions numberOfVersions ;
105
+ pname = "${ pname } -all" ;
106
+ version = "multi-" + lib . concatStringsSep "-"
107
+ ( map ( v : lib . replaceStrings [ "." ] [ "-" ] v ) versions ) ;
57
108
} ;
58
109
}
0 commit comments