1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
{ buildGoModule
, fetchFromGitHub
, fetchurl
, fetchpatch
, go-bindata
, lib
, perl
, pkg-config
, rustPlatform
, stdenv
, libiconv
, nixosTests
}:
let
version = "2.7.1";
ui_version = "OSS-v${version}";
libflux_version = "0.193.0";
src = fetchFromGitHub {
owner = "influxdata";
repo = "influxdb";
rev = "v${version}";
hash = "sha256-JWu4V2k8ItbzBa421EtzgMVlDznoDdGjIhfDSaZ0j6c=";
};
ui = fetchurl {
url = "https://github.com/influxdata/ui/releases/download/${ui_version}/build.tar.gz";
hash = "sha256-0k59SKvt9pFt3WSd5PRUThbfbctt2RYtaxaxoyLICm8=";
};
flux = rustPlatform.buildRustPackage {
pname = "libflux";
version = "v${libflux_version}";
src = fetchFromGitHub {
owner = "influxdata";
repo = "flux";
rev = "v${libflux_version}";
hash = "sha256-gx6vnGOFu35wasLl7X/73eDsE0/50cAzjmBjZ+H2Ne4=";
};
patches = [
# Fix build with recent rust versions
(fetchpatch {
url = "https://github.com/influxdata/flux/commit/6dc8054cfeec4b65b5c7ae786d633240868b8589.patch";
stripLen = 2;
extraPrefix = "";
excludes = [ "rust-toolchain.toml" ];
hash = "sha256-w3z+Z26Xhy9TNICyNhc8XiWNSpdLA23ADI4K/AOMYhg=";
})
./no-deny-warnings.patch
];
sourceRoot = "${src.name}/libflux";
cargoSha256 = "sha256-MoI5nxLGA/3pduZ+vgmSG3lm3Nx58SP+6WXQl2pX9Lc=";
nativeBuildInputs = [ rustPlatform.bindgenHook ];
buildInputs = lib.optional stdenv.isDarwin libiconv;
pkgcfg = ''
Name: flux
Version: ${libflux_version}
Description: Library for the InfluxData Flux engine
Cflags: -I/out/include
Libs: -L/out/lib -lflux -lpthread
'';
passAsFile = [ "pkgcfg" ];
postInstall = ''
mkdir -p $out/include $out/pkgconfig
cp -r $NIX_BUILD_TOP/source/libflux/include/influxdata $out/include
substitute $pkgcfgPath $out/pkgconfig/flux.pc \
--replace /out $out
'' + lib.optionalString stdenv.isDarwin ''
install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib
'';
};
in buildGoModule {
pname = "influxdb";
version = version;
inherit src;
nativeBuildInputs = [ go-bindata pkg-config perl ];
vendorHash = "sha256-5b1WRq3JndkOkKBhMzGZnSyBDY5Lk0UGe/WGHQJp0CQ=";
subPackages = [ "cmd/influxd" "cmd/telemetryd" ];
PKG_CONFIG_PATH = "${flux}/pkgconfig";
postPatch = ''
# use go-bindata from environment
substituteInPlace static/static.go \
--replace 'go run github.com/kevinburke/go-bindata/' ""
'';
# Check that libflux and the UI are at the right version, and embed
# the UI assets into the Go source tree.
preBuild = ''
(
flux_ver=$(grep github.com/influxdata/flux go.mod | awk '{print $2}')
if [ "$flux_ver" != "v${libflux_version}" ]; then
echo "go.mod wants libflux $flux_ver, but nix derivation provides ${libflux_version}"
exit 1
fi
ui_ver=$(egrep 'UI_RELEASE=".*"' scripts/fetch-ui-assets.sh | cut -d'"' -f2)
if [ "$ui_ver" != "${ui_version}" ]; then
echo "scripts/fetch-ui-assets.sh wants UI $ui_ver, but nix derivation provides ${ui_version}"
exit 1
fi
)
mkdir -p static/data
tar -xzf ${ui} -C static/data
pushd static
go generate
popd
'';
tags = [ "assets" ];
ldflags = [ "-X main.commit=v${version}" "-X main.version=${version}" ];
passthru.tests = { inherit (nixosTests) influxdb2; };
meta = with lib; {
description = "An open-source distributed time series database";
license = licenses.mit;
homepage = "https://influxdata.com/";
maintainers = with maintainers; [ abbradar ];
};
}
|