2020-11-24 16:06:39 +01:00
|
|
|
{ buildGoModule
|
|
|
|
, buildGoPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, go-bindata
|
|
|
|
, lib
|
|
|
|
, llvmPackages
|
|
|
|
, mkYarnPackage
|
|
|
|
, pkg-config
|
|
|
|
, rustPlatform
|
2021-05-16 13:32:20 +02:00
|
|
|
, stdenv
|
|
|
|
, libiconv
|
2020-11-24 16:06:39 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
# Note for maintainers: use ./update-influxdb2.sh to update the Yarn
|
|
|
|
# dependencies nix expression.
|
|
|
|
|
|
|
|
let
|
2021-05-14 10:37:36 +02:00
|
|
|
version = "2.0.6";
|
|
|
|
shorthash = "4db98b4c9a"; # git rev-parse HEAD with 2.0.6 checked out
|
|
|
|
libflux_version = "0.115.0";
|
2020-11-24 16:06:39 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "influxdata";
|
|
|
|
repo = "influxdb";
|
|
|
|
rev = "v${version}";
|
2021-05-14 10:37:36 +02:00
|
|
|
sha256 = "1x74p87csx4m4cgijk57xs75nikv3bnh7skgnzk30ab1ar13iirw";
|
2020-11-24 16:06:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
ui = mkYarnPackage {
|
|
|
|
src = src;
|
|
|
|
packageJSON = ./influx-ui-package.json;
|
|
|
|
yarnLock = "${src}/ui/yarn.lock";
|
|
|
|
yarnNix = ./influx-ui-yarndeps.nix;
|
|
|
|
configurePhase = ''
|
|
|
|
cp -r $node_modules ui/node_modules
|
2021-05-14 10:37:36 +02:00
|
|
|
rsync -r $node_modules/../deps/influxdb-ui/node_modules/ ui/node_modules
|
2020-11-24 16:06:39 +01:00
|
|
|
'';
|
|
|
|
INFLUXDB_SHA = shorthash;
|
|
|
|
buildPhase = ''
|
|
|
|
pushd ui
|
|
|
|
yarn build:ci
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mv ui/build $out
|
|
|
|
'';
|
|
|
|
distPhase = "true";
|
|
|
|
};
|
|
|
|
|
|
|
|
flux = rustPlatform.buildRustPackage {
|
|
|
|
pname = "libflux";
|
|
|
|
version = "v${libflux_version}";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "influxdata";
|
|
|
|
repo = "flux";
|
|
|
|
rev = "v${libflux_version}";
|
2021-05-14 10:37:36 +02:00
|
|
|
sha256 = "0zplwsk9xidv8l9sqbxqivy6q20ryd31fhrzspn1mjn4i45kkwz1";
|
2020-11-24 16:06:39 +01:00
|
|
|
};
|
|
|
|
sourceRoot = "source/libflux";
|
2021-05-14 10:37:36 +02:00
|
|
|
cargoSha256 = "06gh466q7qkid0vs5scic0qqlz3h81yb00nwn8nwq8ppr5z2ijyq";
|
2020-11-24 16:06:39 +01:00
|
|
|
nativeBuildInputs = [ llvmPackages.libclang ];
|
2021-05-16 13:32:20 +02: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 10:23:57 +02:00
|
|
|
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
|
2020-11-24 16:06:39 +01: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 13:32:20 +02:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib
|
2020-11-24 16:06:39 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in buildGoModule {
|
|
|
|
pname = "influxdb";
|
|
|
|
version = version;
|
|
|
|
src = src;
|
|
|
|
|
2021-02-06 17:14:45 +01:00
|
|
|
nativeBuildInputs = [ go-bindata pkg-config ];
|
2020-11-24 16:06:39 +01:00
|
|
|
|
2021-05-14 10:37:36 +02:00
|
|
|
vendorSha256 = "03pabm0h9q0v5dfdq9by2l2n32bz9imwalz0aw897vsrfhci0ldf";
|
2020-11-24 16:06:39 +01:00
|
|
|
subPackages = [ "cmd/influxd" "cmd/influx" ];
|
|
|
|
|
|
|
|
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.
|
|
|
|
preBuild = ''
|
|
|
|
ln -s ${ui} ui/build
|
|
|
|
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
|
|
|
|
export buildFlagsArray=(
|
|
|
|
-tags="assets"
|
|
|
|
-ldflags="-X main.commit=${shorthash} -X main.version=${version}"
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "An open-source distributed time series database";
|
|
|
|
license = licenses.mit;
|
|
|
|
homepage = "https://influxdata.com/";
|
|
|
|
maintainers = with maintainers; [ danderson ];
|
|
|
|
};
|
|
|
|
}
|