From 8888330a9d0fcd6d020342230c868ffedc012164 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 28 Nov 2021 01:27:34 -0800 Subject: [PATCH] influxdb2: 2.0.8 -> 2.1.1 * libflux: 0.124.0 -> 0.139.0; as specified in influxdb 2.1's release notes * UI: 2.0.8 -> 2.1.2; matching what influxdb 2.1.1 requires * Add checks in influxdb2's build to verify that libflux and the UI are at the version specified by upstream. * The CLI got split into a separate repository for reasons to do with influx's cloud service, and its version has also been decoupled from the main influxdb repository. Link it back into the influxdb2 derivation, for compatibility with the previous derivation versions. --- pkgs/servers/nosql/influxdb2/default.nix | 83 ++++++++++++------- .../nosql/influxdb2/update-influxdb2.sh | 17 ---- 2 files changed, 53 insertions(+), 47 deletions(-) delete mode 100755 pkgs/servers/nosql/influxdb2/update-influxdb2.sh diff --git a/pkgs/servers/nosql/influxdb2/default.nix b/pkgs/servers/nosql/influxdb2/default.nix index f786171d709f..d793551b741b 100644 --- a/pkgs/servers/nosql/influxdb2/default.nix +++ b/pkgs/servers/nosql/influxdb2/default.nix @@ -1,35 +1,32 @@ -{ buildGoModule -, buildGoPackage +{ buildGo117Module , fetchFromGitHub , fetchurl , go-bindata , lib , llvmPackages +, perl , pkg-config , rustPlatform , stdenv , libiconv }: -# Note for maintainers: use ./update-influxdb2.sh to update the Yarn -# dependencies nix expression. - let - version = "2.0.8"; - shorthash = "e91d41810f"; # git rev-parse HEAD with 2.0.8 checked out - libflux_version = "0.124.0"; + version = "2.1.1"; + ui_version = "2.1.2"; + libflux_version = "0.139.0"; + cli_version = "2.2.1"; src = fetchFromGitHub { owner = "influxdata"; repo = "influxdb"; rev = "v${version}"; - sha256 = "0hbinnja13xr9ziyynjsnsbrxmyrvag7xdgfwq2ya28g07lw5wgq"; + sha256 = "sha256-wf01DhB1ampZuWPkHUEOf3KJK4GjeOAPL3LG2+g4NGY="; }; ui = fetchurl { - url = "https://github.com/influxdata/ui/releases/download/OSS-v${version}/build.tar.gz"; - # https://github.com/influxdata/ui/releases/download/OSS-v${version}/sha256.txt - sha256 = "94965ae999a1098c26128141fbb849be3da9a723d509118eb6e0db4384ee01fc"; + url = "https://github.com/influxdata/ui/releases/download/OSS-${ui_version}/build.tar.gz"; + sha256 = "sha256-fXjShNJfKN/ZQNQHoX9/Ou4XBrXavCN+rcO+8AMc5Ug="; }; flux = rustPlatform.buildRustPackage { @@ -39,10 +36,10 @@ let owner = "influxdata"; repo = "flux"; rev = "v${libflux_version}"; - sha256 = "1g1qilfzxqbbjbfvgkf7k7spcnhzvlmrqacpqdl05418ywkp3v29"; + sha256 = "sha256-cELeWZXGVLFoPYfBoBP8NeLBVFIb5o+lWyto42BLyXY="; }; sourceRoot = "source/libflux"; - cargoSha256 = "0farcjwnwwgfvcgbs5r6vsdrsiwq2mp82sjxkqb1pzqfls4ixcxj"; + cargoSha256 = "sha256-wFgawxgqZqoPnOXJD3r5t2n7Y2bTAkBbBxeBtFEF7N4="; nativeBuildInputs = [ llvmPackages.libclang ]; buildInputs = lib.optional stdenv.isDarwin libiconv; LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; @@ -63,36 +60,62 @@ let install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib ''; }; -in buildGoModule { + + cli = buildGo117Module { + pname = "influxdb-cli"; + version = version; + src = fetchFromGitHub { + owner = "influxdata"; + repo = "influx-cli"; + rev = "v${cli_version}"; + sha256 = "sha256-9FUchI93xLpQwtpbr5S3GfVrApHaemwbnRPIfAWmG6Y="; + }; + + vendorSha256 = "sha256-Boz1G8g0fjjlflxZh4V8sd/v0bE9Oy3DpqywOpKxjd0="; + subPackages = [ "cmd/influx" ]; + ldflags = [ "-X main.commit=v${cli_version}" "-X main.version=${cli_version}" ]; + }; +in buildGo117Module { pname = "influxdb"; version = version; src = src; nativeBuildInputs = [ go-bindata pkg-config ]; - vendorSha256 = "1kar88vlm6px7smlnajpyf8qx6d481xk979qafpfb1xy8931781m"; - subPackages = [ "cmd/influxd" "cmd/influx" ]; + vendorSha256 = "sha256-GVLAzVJzSsC10ZWDZPP8upydwZG21E+zQ6sMKm1lCY0="; + subPackages = [ "cmd/influxd" ]; PKG_CONFIG_PATH = "${flux}/pkgconfig"; - # We have to run a bunch of go:generate commands to embed the UI - # assets into the source code. Ideally we'd run `make generate`, but - # that ends up running a ton of non-hermetic stuff. Instead, we find - # the relevant go:generate directives, and run them by hand without - # breaking hermeticity. + # Check that libflux and the UI are at the right version, and embed + # the UI assets into the Go source tree. preBuild = '' - tar -xzf ${ui} -C static/data + ( + 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 - grep -RI -e 'go:generate.*go-bindata' | cut -f1 -d: | while read -r filename; do - sed -i -e 's/go:generate.*go-bindata/go:generate go-bindata/' $filename - pushd $(dirname $filename) - go generate - popd - done + ui_ver=$(grep influxdata/ui/releases scripts/fetch-ui-assets.sh | ${perl}/bin/perl -pe 's#.*/OSS-([^/]+)/.*#$1#') + 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 + ''; + postInstall = '' + ln -s ${cli}/bin/influx $out/bin/influx ''; tags = [ "assets" ]; - ldflags = [ "-X main.commit=${shorthash}" "-X main.version=${version}" ]; + ldflags = [ "-X main.commit=v${version}" "-X main.version=${version}" ]; meta = with lib; { description = "An open-source distributed time series database"; diff --git a/pkgs/servers/nosql/influxdb2/update-influxdb2.sh b/pkgs/servers/nosql/influxdb2/update-influxdb2.sh deleted file mode 100755 index 826fa9251577..000000000000 --- a/pkgs/servers/nosql/influxdb2/update-influxdb2.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -I nixpkgs=../../../../ -i bash -p wget yarn2nix - -set -euo pipefail - -if [ "$#" -ne 1 ] || [[ "$1" == -* ]]; then - echo "Regenerates the Yarn dependency lock files for the influxdb UI." - echo "Usage: $0 " - exit 1 -fi - -INFLUXDB_SRC="https://raw.githubusercontent.com/influxdata/influxdb/$1" - -wget "$INFLUXDB_SRC/ui/package.json" -O influx-ui-package.json -wget "$INFLUXDB_SRC/ui/yarn.lock" -O influx-ui-yarndeps.lock -yarn2nix --lockfile=influx-ui-yarndeps.lock > influx-ui-yarndeps.nix -rm influx-ui-yarndeps.lock