2021-04-01 12:22:51 +02:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, rustPlatform
|
|
|
|
, pkg-config
|
2021-06-11 13:18:56 +02:00
|
|
|
, llvmPackages
|
|
|
|
, openssl
|
2021-04-01 12:22:51 +02:00
|
|
|
, protobuf
|
2021-06-11 13:18:56 +02:00
|
|
|
, rdkafka
|
|
|
|
, oniguruma
|
|
|
|
, zstd
|
2021-04-01 12:22:51 +02:00
|
|
|
, Security
|
|
|
|
, libiconv
|
|
|
|
, coreutils
|
|
|
|
, CoreServices
|
2021-06-11 13:18:56 +02:00
|
|
|
, tzdata
|
|
|
|
# kafka is optional but one of the most used features
|
|
|
|
, enableKafka ? true
|
|
|
|
# TODO investigate adding "api" "api-client" "vrl-cli" and various "vendor-*"
|
|
|
|
# "disk-buffer" is using leveldb TODO: investigate how useful
|
|
|
|
# it would be, perhaps only for massive scale?
|
|
|
|
, features ? ([ "sinks" "sources" "transforms" ]
|
|
|
|
# the second feature flag is passed to the rdkafka dependency
|
|
|
|
# building on linux fails without this feature flag (both x86_64 and AArch64)
|
|
|
|
++ (lib.optionals enableKafka [ "rdkafka-plain" "rdkafka/dynamic_linking" ])
|
|
|
|
++ (lib.optional stdenv.targetPlatform.isUnix "unix"))
|
2019-10-28 06:35:02 +01:00
|
|
|
}:
|
|
|
|
|
2021-10-24 03:12:05 +02:00
|
|
|
let
|
2019-10-28 06:35:02 +01:00
|
|
|
pname = "vector";
|
2021-10-24 03:12:05 +02:00
|
|
|
version = "0.17.3";
|
|
|
|
in
|
|
|
|
rustPlatform.buildRustPackage {
|
|
|
|
inherit pname version;
|
2019-12-15 03:26:48 +01:00
|
|
|
|
2019-10-28 06:35:02 +01:00
|
|
|
src = fetchFromGitHub {
|
2021-04-01 12:22:51 +02:00
|
|
|
owner = "timberio";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-10-24 03:12:05 +02:00
|
|
|
sha256 = "sha256-1Z2GtzWkS7cxzCs+RBKMtWbzIIt4aeS1Iy9kMBEeDMw=";
|
2019-10-28 06:35:02 +01:00
|
|
|
};
|
|
|
|
|
2021-10-24 03:12:05 +02:00
|
|
|
cargoSha256 = "sha256-UEGdvyRPPh5Kb9+0qFyv8UBFslOKn5/R/ineawFA91w=";
|
2020-03-29 10:18:27 +02:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2021-06-11 13:18:56 +02:00
|
|
|
buildInputs = [ oniguruma openssl protobuf rdkafka zstd ]
|
2021-08-07 12:07:36 +02:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Security libiconv coreutils CoreServices ];
|
2019-10-28 06:35:02 +01:00
|
|
|
|
|
|
|
# needed for internal protobuf c wrapper library
|
2021-04-01 12:22:51 +02:00
|
|
|
PROTOC = "${protobuf}/bin/protoc";
|
|
|
|
PROTOC_INCLUDE = "${protobuf}/include";
|
2021-06-11 13:18:56 +02:00
|
|
|
RUSTONIG_SYSTEM_LIBONIG = true;
|
|
|
|
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
|
2019-10-28 06:35:02 +01:00
|
|
|
|
2021-03-12 03:47:27 +01:00
|
|
|
cargoBuildFlags = [ "--no-default-features" "--features" (lib.concatStringsSep "," features) ];
|
2021-06-11 13:18:56 +02:00
|
|
|
# TODO investigate compilation failure for tests
|
|
|
|
# dev dependency includes httpmock which depends on iashc which depends on curl-sys with http2 feature enabled
|
|
|
|
# compilation fails because of a missing http2 include
|
|
|
|
doCheck = !stdenv.isDarwin;
|
2021-08-29 02:33:29 +02:00
|
|
|
# healthcheck_grafana_cloud is trying to make a network access
|
|
|
|
# test_stream_errors is flaky on linux-aarch64
|
2021-09-17 08:53:34 +02:00
|
|
|
# tcp_with_tls_intermediate_ca is flaky on linux-x86_64
|
2021-08-29 02:33:29 +02:00
|
|
|
checkPhase = ''
|
|
|
|
TZDIR=${tzdata}/share/zoneinfo cargo test \
|
|
|
|
--no-default-features \
|
|
|
|
--features ${lib.concatStringsSep "," features} \
|
|
|
|
-- --test-threads 1 \
|
|
|
|
--skip=sinks::loki::tests::healthcheck_grafana_cloud \
|
2021-09-17 08:53:34 +02:00
|
|
|
--skip=kubernetes::api_watcher::tests::test_stream_errors \
|
2021-10-24 03:12:05 +02:00
|
|
|
--skip=sources::socket::test::tcp_with_tls_intermediate_ca \
|
|
|
|
--skip=sources::host_metrics::cgroups::tests::generates_cgroups_metrics
|
2021-08-29 02:33:29 +02:00
|
|
|
'';
|
2020-09-14 04:37:21 +02:00
|
|
|
|
|
|
|
# recent overhauls of DNS support in 0.9 mean that we try to resolve
|
|
|
|
# vector.dev during the checkPhase, which obviously isn't going to work.
|
|
|
|
# these tests in the DNS module are trivial though, so stubbing them out is
|
|
|
|
# fine IMO.
|
2020-10-23 14:09:39 +02:00
|
|
|
#
|
|
|
|
# the geoip transform yields maxmindb.so which contains references to rustc.
|
|
|
|
# neither figured out why the shared object is included in the output
|
|
|
|
# (it doesn't seem to be a runtime dependencies of the geoip transform),
|
|
|
|
# nor do I know why it depends on rustc.
|
|
|
|
# However, in order for the closure size to stay at a reasonable level,
|
|
|
|
# transforms-geoip is patched out of Cargo.toml for now - unless explicitly asked for.
|
2021-03-12 03:47:27 +01:00
|
|
|
postPatch = ''
|
2020-09-14 04:37:21 +02:00
|
|
|
substituteInPlace ./src/dns.rs \
|
2021-03-12 03:47:27 +01:00
|
|
|
--replace "#[tokio::test]" ""
|
2020-10-23 14:09:39 +02:00
|
|
|
|
|
|
|
${lib.optionalString (!builtins.elem "transforms-geoip" features) ''
|
|
|
|
substituteInPlace ./Cargo.toml --replace '"transforms-geoip",' ""
|
|
|
|
''}
|
2020-09-14 04:37:21 +02:00
|
|
|
'';
|
2019-10-28 06:35:02 +01:00
|
|
|
|
2021-03-12 03:47:27 +01:00
|
|
|
passthru = { inherit features; };
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2019-10-28 06:35:02 +01:00
|
|
|
description = "A high-performance logs, metrics, and events router";
|
2021-04-01 12:22:51 +02:00
|
|
|
homepage = "https://github.com/timberio/vector";
|
|
|
|
license = with licenses; [ asl20 ];
|
2020-11-30 08:34:53 +01:00
|
|
|
maintainers = with maintainers; [ thoughtpolice happysalada ];
|
2019-10-28 06:35:02 +01:00
|
|
|
};
|
|
|
|
}
|