2021-12-16 19:37:21 +00:00
|
|
|
{ buildGoModule
|
2020-11-24 15:06:39 +00:00
|
|
|
, fetchFromGitHub
|
2021-09-20 12:22:05 +01:00
|
|
|
, fetchurl
|
2020-11-24 15:06:39 +00:00
|
|
|
, go-bindata
|
|
|
|
, lib
|
|
|
|
, llvmPackages
|
2021-11-28 09:27:34 +00:00
|
|
|
, perl
|
2020-11-24 15:06:39 +00:00
|
|
|
, pkg-config
|
|
|
|
, rustPlatform
|
2021-05-16 12:32:20 +01:00
|
|
|
, stdenv
|
|
|
|
, libiconv
|
2020-11-24 15:06:39 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-11-28 09:27:34 +00:00
|
|
|
version = "2.1.1";
|
|
|
|
ui_version = "2.1.2";
|
|
|
|
libflux_version = "0.139.0";
|
2020-11-24 15:06:39 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "influxdata";
|
|
|
|
repo = "influxdb";
|
|
|
|
rev = "v${version}";
|
2021-11-28 09:27:34 +00:00
|
|
|
sha256 = "sha256-wf01DhB1ampZuWPkHUEOf3KJK4GjeOAPL3LG2+g4NGY=";
|
2020-11-24 15:06:39 +00:00
|
|
|
};
|
|
|
|
|
2021-09-20 12:22:05 +01:00
|
|
|
ui = fetchurl {
|
2021-11-28 09:27:34 +00:00
|
|
|
url = "https://github.com/influxdata/ui/releases/download/OSS-${ui_version}/build.tar.gz";
|
|
|
|
sha256 = "sha256-fXjShNJfKN/ZQNQHoX9/Ou4XBrXavCN+rcO+8AMc5Ug=";
|
2020-11-24 15:06:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
flux = rustPlatform.buildRustPackage {
|
|
|
|
pname = "libflux";
|
|
|
|
version = "v${libflux_version}";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "influxdata";
|
|
|
|
repo = "flux";
|
|
|
|
rev = "v${libflux_version}";
|
2021-11-28 09:27:34 +00:00
|
|
|
sha256 = "sha256-cELeWZXGVLFoPYfBoBP8NeLBVFIb5o+lWyto42BLyXY=";
|
2020-11-24 15:06:39 +00:00
|
|
|
};
|
|
|
|
sourceRoot = "source/libflux";
|
2021-11-28 09:27:34 +00:00
|
|
|
cargoSha256 = "sha256-wFgawxgqZqoPnOXJD3r5t2n7Y2bTAkBbBxeBtFEF7N4=";
|
2020-11-24 15:06:39 +00:00
|
|
|
nativeBuildInputs = [ llvmPackages.libclang ];
|
2021-05-16 12:32:20 +01:00
|
|
|
buildInputs = lib.optional stdenv.isDarwin libiconv;
|
llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb391ed002046090851a44c452b80bdbd, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2020-10-15 09:23:57 +01:00
|
|
|
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
|
2020-11-24 15:06:39 +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-16 12:32:20 +01:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib
|
2020-11-24 15:06:39 +00:00
|
|
|
'';
|
|
|
|
};
|
2021-11-28 09:27:34 +00:00
|
|
|
|
2021-12-16 19:37:21 +00:00
|
|
|
in buildGoModule {
|
2020-11-24 15:06:39 +00:00
|
|
|
pname = "influxdb";
|
|
|
|
version = version;
|
|
|
|
src = src;
|
|
|
|
|
2021-02-06 16:14:45 +00:00
|
|
|
nativeBuildInputs = [ go-bindata pkg-config ];
|
2020-11-24 15:06:39 +00:00
|
|
|
|
2021-11-28 09:27:34 +00:00
|
|
|
vendorSha256 = "sha256-GVLAzVJzSsC10ZWDZPP8upydwZG21E+zQ6sMKm1lCY0=";
|
2021-12-16 19:37:21 +00:00
|
|
|
subPackages = [ "cmd/influxd" "cmd/telemetryd" ];
|
2020-11-24 15:06:39 +00:00
|
|
|
|
|
|
|
PKG_CONFIG_PATH = "${flux}/pkgconfig";
|
2021-11-28 09:27:34 +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 15:06:39 +00:00
|
|
|
preBuild = ''
|
2021-11-28 09:27:34 +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
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
2021-09-20 12:22:05 +01:00
|
|
|
|
2021-11-28 09:27:34 +00:00
|
|
|
mkdir -p static/data
|
|
|
|
tar -xzf ${ui} -C static/data
|
|
|
|
pushd static
|
|
|
|
go generate
|
|
|
|
popd
|
|
|
|
'';
|
2020-11-24 15:06:39 +00:00
|
|
|
|
2021-08-07 03:28:40 +01:00
|
|
|
tags = [ "assets" ];
|
|
|
|
|
2021-11-28 09:27:34 +00:00
|
|
|
ldflags = [ "-X main.commit=v${version}" "-X main.version=${version}" ];
|
2021-08-07 03:28:40 +01:00
|
|
|
|
2020-11-24 15:06:39 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "An open-source distributed time series database";
|
|
|
|
license = licenses.mit;
|
|
|
|
homepage = "https://influxdata.com/";
|
2021-12-16 19:37:21 +00:00
|
|
|
maintainers = with maintainers; [ abbradar danderson ];
|
2020-11-24 15:06:39 +00:00
|
|
|
};
|
|
|
|
}
|