nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv
2, lib
3, fetchFromGitHub
4, rustPlatform
5, pkg-config
6, openssl
7, protobuf
8, rdkafka
9, oniguruma
10, zstd
11, Security
12, libiconv
13, coreutils
14, CoreServices
15, tzdata
16, cmake
17, perl
18, git
19 # nix has a problem with the `?` in the feature list
20 # enabling kafka will produce a vector with no features at all
21, enableKafka ? false
22 # TODO investigate adding "vrl-cli" and various "vendor-*"
23 # "disk-buffer" is using leveldb TODO: investigate how useful
24 # it would be, perhaps only for massive scale?
25, features ? ([ "api" "api-client" "enrichment-tables" "sinks" "sources" "sources-dnstap" "transforms" "vrl-cli" ]
26 # the second feature flag is passed to the rdkafka dependency
27 # building on linux fails without this feature flag (both x86_64 and AArch64)
28 ++ lib.optionals enableKafka [ "rdkafka?/gssapi-vendored" ]
29 ++ lib.optional stdenv.targetPlatform.isUnix "unix")
30, nix-update-script
31}:
32
33let
34 pname = "vector";
35 version = "0.29.1";
36in
37rustPlatform.buildRustPackage {
38 inherit pname version;
39
40 src = fetchFromGitHub {
41 owner = "vectordotdev";
42 repo = pname;
43 rev = "v${version}";
44 sha256 = "sha256-4WqO7i1xthUU2bTzaS5poTh+wemjvqNAUFIDN73f7kw=";
45 };
46
47 cargoLock = {
48 lockFile = ./Cargo.lock;
49 outputHashes = {
50 "azure_core-0.5.0" = "sha256-fojO7dhntpymMjV58TtYb7N4UN6rOp30D54x09RDXfQ=";
51 "chrono-0.4.24" = "sha256-SVPRfixSt0m14MmOcmBVseC/moj1DIA3B+m0pvT41K0=";
52 "datadog-filter-0.1.0" = "sha256-CNAIoDyJJo+D2Qzt6Fb2FwpQpzX02XurT8j1gHkz1bE=";
53 "heim-0.1.0-rc.1" = "sha256-ODKEQ1udt7FlxI5fvoFMG7C2zmM45eeEYDUEaLTsdYo=";
54 "nix-0.26.2" = "sha256-uquYvRT56lhupkrESpxwKEimRFhmYvri10n3dj0f2yg=";
55 "tokio-util-0.7.4" = "sha256-rAzj44O+GOZhG+o6FVN5qCcG/NWxW8fUpScm+xsRjIs=";
56 "tracing-0.2.0" = "sha256-YAxeEofFA43PX2hafh3RY+C81a2v6n1fGzYz2FycC3M=";
57 };
58 };
59 nativeBuildInputs = [ pkg-config cmake perl git rustPlatform.bindgenHook ];
60 buildInputs = [ oniguruma openssl protobuf rdkafka zstd ]
61 ++ lib.optionals stdenv.isDarwin [ Security libiconv coreutils CoreServices ];
62
63 # needed for internal protobuf c wrapper library
64 PROTOC = "${protobuf}/bin/protoc";
65 PROTOC_INCLUDE = "${protobuf}/include";
66 RUSTONIG_SYSTEM_LIBONIG = true;
67
68 TZDIR = "${tzdata}/share/zoneinfo";
69
70 # needed to dynamically link rdkafka
71 CARGO_FEATURE_DYNAMIC_LINKING=1;
72
73 buildNoDefaultFeatures = true;
74 buildFeatures = features;
75
76 # TODO investigate compilation failure for tests
77 # there are about 100 tests failing (out of 1100) for version 0.22.0
78 doCheck = false;
79
80 checkFlags = [
81 # tries to make a network access
82 "--skip=sinks::loki::tests::healthcheck_grafana_cloud"
83
84 # flaky on linux-aarch64
85 "--skip=kubernetes::api_watcher::tests::test_stream_errors"
86
87 # flaky on linux-x86_64
88 "--skip=sources::socket::test::tcp_with_tls_intermediate_ca"
89 "--skip=sources::host_metrics::cgroups::tests::generates_cgroups_metrics"
90 "--skip=sources::aws_kinesis_firehose::tests::aws_kinesis_firehose_forwards_events"
91 "--skip=sources::aws_kinesis_firehose::tests::aws_kinesis_firehose_forwards_events_gzip_request"
92 "--skip=sources::aws_kinesis_firehose::tests::handles_acknowledgement_failure"
93 ];
94
95 # recent overhauls of DNS support in 0.9 mean that we try to resolve
96 # vector.dev during the checkPhase, which obviously isn't going to work.
97 # these tests in the DNS module are trivial though, so stubbing them out is
98 # fine IMO.
99 #
100 # the geoip transform yields maxmindb.so which contains references to rustc.
101 # neither figured out why the shared object is included in the output
102 # (it doesn't seem to be a runtime dependencies of the geoip transform),
103 # nor do I know why it depends on rustc.
104 # However, in order for the closure size to stay at a reasonable level,
105 # transforms-geoip is patched out of Cargo.toml for now - unless explicitly asked for.
106 postPatch = ''
107 substituteInPlace ./src/dns.rs \
108 --replace "#[tokio::test]" ""
109 '';
110
111 passthru = {
112 inherit features;
113 updateScript = nix-update-script { };
114 };
115
116 meta = with lib; {
117 description = "A high-performance observability data pipeline";
118 homepage = "https://github.com/vectordotdev/vector";
119 license = licenses.mpl20;
120 maintainers = with maintainers; [ thoughtpolice happysalada ];
121 platforms = with platforms; all;
122 };
123}