1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 rustPlatform,
6 pkg-config,
7 openssl,
8 protobuf,
9 rdkafka,
10 oniguruma,
11 zstd,
12 rust-jemalloc-sys,
13 rust-jemalloc-sys-unprefixed,
14 libiconv,
15 coreutils,
16 tzdata,
17 cmake,
18 perl,
19 git,
20 nixosTests,
21 nix-update-script,
22 darwin,
23 zlib,
24}:
25
26let
27 pname = "vector";
28 version = "0.48.0";
29in
30rustPlatform.buildRustPackage {
31 inherit pname version;
32
33 src = fetchFromGitHub {
34 owner = "vectordotdev";
35 repo = "vector";
36 rev = "v${version}";
37 hash = "sha256-qgf3aMZc1cgPlsAzgtaXLUx99KwN5no1amdkwFVyl4Y=";
38 };
39
40 cargoHash = "sha256-t8mfZpLrzrxj1WUpJPqZWyfBf9XobcqZY/hAeVGzhcM=";
41
42 nativeBuildInputs = [
43 pkg-config
44 cmake
45 perl
46 git
47 rustPlatform.bindgenHook
48 ]
49 # Provides the mig command used by the build scripts
50 ++ lib.optional stdenv.hostPlatform.isDarwin darwin.bootstrap_cmds;
51 buildInputs = [
52 oniguruma
53 openssl
54 protobuf
55 rdkafka
56 zstd
57 ]
58 ++ lib.optionals stdenv.hostPlatform.isLinux [ rust-jemalloc-sys-unprefixed ]
59 ++ lib.optionals stdenv.hostPlatform.isDarwin [
60 rust-jemalloc-sys
61 libiconv
62 coreutils
63 zlib
64 ];
65
66 # Rust 1.80.0 introduced the unexepcted_cfgs lint, which requires crates to allowlist custom cfg options that they inspect.
67 # Upstream is working on fixing this in https://github.com/vectordotdev/vector/pull/20949, but silencing the lint lets us build again until then.
68 # TODO remove when upgrading Vector
69 RUSTFLAGS = "--allow dependency_on_unit_never_type_fallback --allow dead_code";
70
71 # Without this, we get SIGSEGV failure
72 RUST_MIN_STACK = 33554432;
73
74 # needed for internal protobuf c wrapper library
75 PROTOC = "${protobuf}/bin/protoc";
76 PROTOC_INCLUDE = "${protobuf}/include";
77 RUSTONIG_SYSTEM_LIBONIG = true;
78
79 TZDIR = "${tzdata}/share/zoneinfo";
80
81 # needed to dynamically link rdkafka
82 CARGO_FEATURE_DYNAMIC_LINKING = 1;
83
84 CARGO_PROFILE_RELEASE_LTO = "fat";
85 CARGO_PROFILE_RELEASE_CODEGEN_UNITS = "1";
86
87 # TODO investigate compilation failure for tests
88 # there are about 100 tests failing (out of 1100) for version 0.22.0
89 doCheck = false;
90
91 checkFlags = [
92 # tries to make a network access
93 "--skip=sinks::loki::tests::healthcheck_grafana_cloud"
94
95 # flaky on linux-aarch64
96 "--skip=kubernetes::api_watcher::tests::test_stream_errors"
97
98 # flaky on linux-x86_64
99 "--skip=sources::socket::test::tcp_with_tls_intermediate_ca"
100 "--skip=sources::host_metrics::cgroups::tests::generates_cgroups_metrics"
101 "--skip=sources::aws_kinesis_firehose::tests::aws_kinesis_firehose_forwards_events"
102 "--skip=sources::aws_kinesis_firehose::tests::aws_kinesis_firehose_forwards_events_gzip_request"
103 "--skip=sources::aws_kinesis_firehose::tests::handles_acknowledgement_failure"
104 ];
105
106 # recent overhauls of DNS support in 0.9 mean that we try to resolve
107 # vector.dev during the checkPhase, which obviously isn't going to work.
108 # these tests in the DNS module are trivial though, so stubbing them out is
109 # fine IMO.
110 #
111 # the geoip transform yields maxmindb.so which contains references to rustc.
112 # neither figured out why the shared object is included in the output
113 # (it doesn't seem to be a runtime dependencies of the geoip transform),
114 # nor do I know why it depends on rustc.
115 # However, in order for the closure size to stay at a reasonable level,
116 # transforms-geoip is patched out of Cargo.toml for now - unless explicitly asked for.
117 postPatch = ''
118 substituteInPlace ./src/dns.rs \
119 --replace-fail "#[tokio::test]" ""
120 '';
121
122 passthru = {
123 tests = {
124 inherit (nixosTests) vector;
125 };
126 updateScript = nix-update-script { };
127 };
128
129 meta = with lib; {
130 description = "High-performance observability data pipeline";
131 homepage = "https://github.com/vectordotdev/vector";
132 license = licenses.mpl20;
133 maintainers = with maintainers; [
134 thoughtpolice
135 happysalada
136 ];
137 platforms = with platforms; all;
138 mainProgram = "vector";
139 };
140}