@@ -1,35 +1,32 @@
1−{ buildGoModule
2−, buildGoPackage
1+{ buildGo117Module
32, fetchFromGitHub
43, fetchurl
54, go-bindata
65, lib
76, llvmPackages
7+, perl
88, pkg-config
99, rustPlatform
1010, stdenv
1111, libiconv
1212}:
1313
14−# Note for maintainers: use ./update-influxdb2.sh to update the Yarn
15−# dependencies nix expression.
16−
1714let
18− version = "2.0.8";
19− shorthash = "e91d41810f"; # git rev-parse HEAD with 2.0.8 checked out
20− libflux_version = "0.124.0";
15+ version = "2.1.1";
16+ ui_version = "2.1.2";
17+ libflux_version = "0.139.0";
18+ cli_version = "2.2.1";
2119
2220 src = fetchFromGitHub {
2321 owner = "influxdata";
2422 repo = "influxdb";
2523 rev = "v${version}";
26− sha256 = "0hbinnja13xr9ziyynjsnsbrxmyrvag7xdgfwq2ya28g07lw5wgq";
24+ sha256 = "sha256-wf01DhB1ampZuWPkHUEOf3KJK4GjeOAPL3LG2+g4NGY=";
2725 };
2826
2927 ui = fetchurl {
30− url = "https://github.com/influxdata/ui/releases/download/OSS-v${version}/build.tar.gz";
31− # https://github.com/influxdata/ui/releases/download/OSS-v${version}/sha256.txt
32− sha256 = "94965ae999a1098c26128141fbb849be3da9a723d509118eb6e0db4384ee01fc";
28+ url = "https://github.com/influxdata/ui/releases/download/OSS-${ui_version}/build.tar.gz";
29+ sha256 = "sha256-fXjShNJfKN/ZQNQHoX9/Ou4XBrXavCN+rcO+8AMc5Ug=";
3330 };
3431
3532 flux = rustPlatform.buildRustPackage {
@@ -39,10 +36,10 @@ let
3936 owner = "influxdata";
4037 repo = "flux";
4138 rev = "v${libflux_version}";
42− sha256 = "1g1qilfzxqbbjbfvgkf7k7spcnhzvlmrqacpqdl05418ywkp3v29";
39+ sha256 = "sha256-cELeWZXGVLFoPYfBoBP8NeLBVFIb5o+lWyto42BLyXY=";
4340 };
4441 sourceRoot = "source/libflux";
45− cargoSha256 = "0farcjwnwwgfvcgbs5r6vsdrsiwq2mp82sjxkqb1pzqfls4ixcxj";
42+ cargoSha256 = "sha256-wFgawxgqZqoPnOXJD3r5t2n7Y2bTAkBbBxeBtFEF7N4=";
4643 nativeBuildInputs = [ llvmPackages.libclang ];
4744 buildInputs = lib.optional stdenv.isDarwin libiconv;
4845 LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
@@ -63,36 +60,62 @@ let
6360 install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib
6461 '';
6562 };
66−in buildGoModule {
63+
64+ cli = buildGo117Module {
65+ pname = "influxdb-cli";
66+ version = version;
67+ src = fetchFromGitHub {
68+ owner = "influxdata";
69+ repo = "influx-cli";
70+ rev = "v${cli_version}";
71+ sha256 = "sha256-9FUchI93xLpQwtpbr5S3GfVrApHaemwbnRPIfAWmG6Y=";
72+ };
73+
74+ vendorSha256 = "sha256-Boz1G8g0fjjlflxZh4V8sd/v0bE9Oy3DpqywOpKxjd0=";
75+ subPackages = [ "cmd/influx" ];
76+ ldflags = [ "-X main.commit=v${cli_version}" "-X main.version=${cli_version}" ];
77+ };
78+in buildGo117Module {
6779 pname = "influxdb";
6880 version = version;
6981 src = src;
7082
7183 nativeBuildInputs = [ go-bindata pkg-config ];
7284
73− vendorSha256 = "1kar88vlm6px7smlnajpyf8qx6d481xk979qafpfb1xy8931781m";
74− subPackages = [ "cmd/influxd" "cmd/influx" ];
85+ vendorSha256 = "sha256-GVLAzVJzSsC10ZWDZPP8upydwZG21E+zQ6sMKm1lCY0=";
86+ subPackages = [ "cmd/influxd" ];
7587
7688 PKG_CONFIG_PATH = "${flux}/pkgconfig";
77− # We have to run a bunch of go:generate commands to embed the UI
78− # assets into the source code. Ideally we'd run `make generate`, but
79− # that ends up running a ton of non-hermetic stuff. Instead, we find
80− # the relevant go:generate directives, and run them by hand without
81− # breaking hermeticity.
89+ # Check that libflux and the UI are at the right version, and embed
90+ # the UI assets into the Go source tree.
8291 preBuild = ''
83− tar -xzf ${ui} -C static/data
92+ (
93+ flux_ver=$(grep github.com/influxdata/flux go.mod | awk '{print $2}')
94+ if [ "$flux_ver" != "v${libflux_version}" ]; then
95+ echo "go.mod wants libflux $flux_ver, but nix derivation provides ${libflux_version}"
96+ exit 1
97+ fi
98+
99+ ui_ver=$(grep influxdata/ui/releases scripts/fetch-ui-assets.sh | ${perl}/bin/perl -pe 's#.*/OSS-([^/]+)/.*#$1#')
100+ if [ "$ui_ver" != "${ui_version}" ]; then
101+ echo "scripts/fetch-ui-assets.sh wants UI $ui_ver, but nix derivation provides ${ui_version}"
102+ exit 1
103+ fi
104+ )
84105
85− grep -RI -e 'go:generate.*go-bindata' | cut -f1 -d: | while read -r filename; do
86− sed -i -e 's/go:generate.*go-bindata/go:generate go-bindata/' $filename
87− pushd $(dirname $filename)
88− go generate
89− popd
90− done
106+ mkdir -p static/data
107+ tar -xzf ${ui} -C static/data
108+ pushd static
109+ go generate
110+ popd
111+ '';
112+ postInstall = ''
113+ ln -s ${cli}/bin/influx $out/bin/influx
91114 '';
92115
93116 tags = [ "assets" ];
94117
95− ldflags = [ "-X main.commit=${shorthash}" "-X main.version=${version}" ];
118+ ldflags = [ "-X main.commit=v${version}" "-X main.version=${version}" ];
96119
97120 meta = with lib; {
98121 description = "An open-source distributed time series database";