2020-11-24 20:58:05 +00:00
|
|
|
{ buildGoModule
|
|
|
|
, fetchFromGitHub
|
2021-09-22 15:38:15 +00:00
|
|
|
, fetchurl
|
2022-10-21 18:38:19 +00:00
|
|
|
, fetchpatch
|
2020-11-24 20:58:05 +00:00
|
|
|
, go-bindata
|
|
|
|
, lib
|
|
|
|
, llvmPackages
|
2021-12-19 01:06:50 +00:00
|
|
|
, perl
|
2020-11-24 20:58:05 +00:00
|
|
|
, pkg-config
|
|
|
|
, rustPlatform
|
2021-05-20 23:08:51 +00:00
|
|
|
, stdenv
|
|
|
|
, libiconv
|
2020-11-24 20:58:05 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-10-06 18:32:54 +00:00
|
|
|
version = "2.4.0";
|
|
|
|
# Despite the name, this is not a rolling release. This is the
|
|
|
|
# version of the UI assets for 2.4.0, as specified in
|
|
|
|
# scripts/fetch-ui-assets.sh in the 2.4.0 tag of influxdb.
|
|
|
|
ui_version = "Master";
|
|
|
|
libflux_version = "0.179.0";
|
2020-11-24 20:58:05 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "influxdata";
|
|
|
|
repo = "influxdb";
|
|
|
|
rev = "v${version}";
|
2022-10-06 18:32:54 +00:00
|
|
|
sha256 = "sha256-ufJnrVWVfia2/xLRmFkauCw8ktdSJUybJkv42Gd0npg=";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
|
2021-09-22 15:38:15 +00:00
|
|
|
ui = fetchurl {
|
2021-12-19 01:06:50 +00:00
|
|
|
url = "https://github.com/influxdata/ui/releases/download/OSS-${ui_version}/build.tar.gz";
|
2022-10-06 18:32:54 +00:00
|
|
|
sha256 = "sha256-YKDp1jLyo4n+YTeMaWl8dhN4Lr3H8FXV7stJ3p3zFe8=";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
flux = rustPlatform.buildRustPackage {
|
|
|
|
pname = "libflux";
|
|
|
|
version = "v${libflux_version}";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "influxdata";
|
|
|
|
repo = "flux";
|
|
|
|
rev = "v${libflux_version}";
|
2022-10-06 18:32:54 +00:00
|
|
|
sha256 = "sha256-xcsmvT8Ve1WbfwrdVPnJcj7RAvrk795N3C95ubbGig0=";
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
patches = [
|
|
|
|
# https://github.com/influxdata/flux/pull/5273
|
|
|
|
# fix compile error with Rust 1.64
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/influxdata/flux/commit/20ca62138a0669f2760dd469ca41fc333e04b8f2.patch";
|
|
|
|
stripLen = 2;
|
|
|
|
extraPrefix = "";
|
|
|
|
sha256 = "sha256-Fb4CuH9ZvrPha249dmLLI8MqSNQRKqKPxPbw2pjqwfY=";
|
|
|
|
})
|
|
|
|
];
|
2020-11-24 20:58:05 +00:00
|
|
|
sourceRoot = "source/libflux";
|
2022-10-06 18:32:54 +00:00
|
|
|
cargoSha256 = "sha256-+hJQFV0tWeTQDN560DzROUNpdkcZ5h2sc13akHCgqPc=";
|
2020-11-24 20:58:05 +00:00
|
|
|
nativeBuildInputs = [ llvmPackages.libclang ];
|
2021-05-20 23:08:51 +00:00
|
|
|
buildInputs = lib.optional stdenv.isDarwin libiconv;
|
|
|
|
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
|
2020-11-24 20:58:05 +00:00
|
|
|
pkgcfg = ''
|
|
|
|
Name: flux
|
|
|
|
Version: ${libflux_version}
|
|
|
|
Description: Library for the InfluxData Flux engine
|
|
|
|
Cflags: -I/out/include
|
|
|
|
Libs: -L/out/lib -lflux -ldl -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
|
2021-05-20 23:08:51 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib
|
2020-11-24 20:58:05 +00:00
|
|
|
'';
|
|
|
|
};
|
2021-12-19 01:06:50 +00:00
|
|
|
|
2020-11-24 20:58:05 +00:00
|
|
|
in buildGoModule {
|
|
|
|
pname = "influxdb";
|
|
|
|
version = version;
|
|
|
|
src = src;
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
nativeBuildInputs = [ go-bindata pkg-config perl ];
|
2020-11-24 20:58:05 +00:00
|
|
|
|
2022-10-06 18:32:54 +00:00
|
|
|
vendorSha256 = "sha256-DZsd6qPKfRbnvz0UAww+ubaeTEqQxLeil1S3SZAmmJk=";
|
2021-12-19 01:06:50 +00:00
|
|
|
subPackages = [ "cmd/influxd" "cmd/telemetryd" ];
|
2020-11-24 20:58:05 +00:00
|
|
|
|
|
|
|
PKG_CONFIG_PATH = "${flux}/pkgconfig";
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# use go-bindata from environment
|
|
|
|
substituteInPlace static/static.go \
|
|
|
|
--replace 'go run github.com/kevinburke/go-bindata/' ""
|
|
|
|
'';
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
# Check that libflux and the UI are at the right version, and embed
|
|
|
|
# the UI assets into the Go source tree.
|
2020-11-24 20:58:05 +00:00
|
|
|
preBuild = ''
|
2021-12-19 01:06:50 +00:00
|
|
|
(
|
|
|
|
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
|
2021-09-22 15:38:15 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
ui_ver=$(egrep 'influxdata/ui/releases/.*/sha256.txt' scripts/fetch-ui-assets.sh | perl -pe 's#.*/OSS-([^/]+)/.*#$1#')
|
2021-12-19 01:06:50 +00:00
|
|
|
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
|
2020-11-24 20:58:05 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-08 23:34:03 +00:00
|
|
|
tags = [ "assets" ];
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
ldflags = [ "-X main.commit=v${version}" "-X main.version=${version}" ];
|
2021-08-08 23:34:03 +00:00
|
|
|
|
2020-11-24 20:58:05 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "An open-source distributed time series database";
|
|
|
|
license = licenses.mit;
|
|
|
|
homepage = "https://influxdata.com/";
|
2021-12-19 01:06:50 +00:00
|
|
|
maintainers = with maintainers; [ abbradar danderson ];
|
2020-11-24 20:58:05 +00:00
|
|
|
};
|
|
|
|
}
|