{ stdenv, lib, fetchFromGitHub, installShellFiles, rustPlatform, pkg-config, openssl, protobuf, rdkafka, oniguruma, zstd, rust-jemalloc-sys, rust-jemalloc-sys-unprefixed, libiconv, coreutils, tzdata, cmake, cyrus_sasl, perl, git, nixosTests, nix-update-script, darwin, versionCheckHook, zlib, }: rustPlatform.buildRustPackage (finalAttrs: { pname = "vector"; version = "0.57.0"; src = fetchFromGitHub { owner = "vectordotdev"; repo = "vector"; tag = "v${finalAttrs.version}"; hash = "sha256-x4yfC/qAMRM7X19usonsp8GSJHwIsn0zoX0owLn2EXs="; }; cargoHash = "sha256-H26tUF+i/79t7W2BVjh2bVRCGZK8rgazHzlTF4L2jyA="; nativeBuildInputs = [ pkg-config cmake perl git rustPlatform.bindgenHook installShellFiles ] # Provides the mig command used by the build scripts ++ lib.optional stdenv.hostPlatform.isDarwin darwin.bootstrap_cmds; buildInputs = [ cyrus_sasl oniguruma openssl protobuf rdkafka zstd ] ++ lib.optionals stdenv.hostPlatform.isLinux [ rust-jemalloc-sys-unprefixed ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ rust-jemalloc-sys libiconv coreutils zlib ]; env = { # Fix build with gcc 15 # https://github.com/vectordotdev/vector/issues/22888 NIX_CFLAGS_COMPILE = "-std=gnu17"; # Without this, we get SIGSEGV failure RUST_MIN_STACK = 33554432; # needed for internal protobuf c wrapper library PROTOC = "${protobuf}/bin/protoc"; RUSTONIG_SYSTEM_LIBONIG = true; TZDIR = "${tzdata}/share/zoneinfo"; # needed to dynamically link rdkafka CARGO_FEATURE_DYNAMIC_LINKING = 1; CARGO_PROFILE_RELEASE_LTO = "fat"; CARGO_PROFILE_RELEASE_CODEGEN_UNITS = "1"; }; doCheck = true; checkType = "debug"; checkFlags = [ # Tries to make a network access "--skip=dns::tests::resolve_example" "--skip=sinks::loki::tests::healthcheck_grafana_cloud" # Requires secret server "--skip=secrets::exec::tests::test_exec_backend::case_1" "--skip=secrets::exec::tests::test_exec_backend::case_2" "--skip=secrets::exec::tests::test_exec_backend_missing_secrets" # Flakey "--skip=sources::host_metrics::cgroups::tests::generates_cgroups_metrics" "--skip=sources::host_metrics::cpu::tests::generates_cpu_metrics" "--skip=sources::internal_logs::tests::repeated_logs_are_not_rate_limited" "--skip=topology::test::reload::topology_reload_preserves_enrichment_table_state" # Requires access to journalctl "--skip=sources::journald::tests::emits_cursor" "--skip=sources::journald::tests::excludes_matches" "--skip=sources::journald::tests::excludes_units" "--skip=sources::journald::tests::handles_acknowledgements" "--skip=sources::journald::tests::handles_checkpoint" "--skip=sources::journald::tests::handles_missing_timestamp" "--skip=sources::journald::tests::includes_kernel" "--skip=sources::journald::tests::includes_matches" "--skip=sources::journald::tests::includes_units" "--skip=sources::journald::tests::parses_array_fields" "--skip=sources::journald::tests::parses_array_messages" "--skip=sources::journald::tests::parses_string_sequences" "--skip=sources::journald::tests::reads_journal" # No multicast access available in sandbox "--skip=sources::socket::test::multicast_and_unicast_udp_message" "--skip=sources::socket::test::multicast_udp_message" "--skip=sources::socket::test::multiple_multicast_addresses_udp_message" "--skip=sources::syslog::test::test_udp_syslog" ] ++ lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isDarwin) [ # Fails on aarch64-darwin (https://github.com/vectordotdev/vector/issues/23813) "--skip=sources::file::tests::file_start_position_server_restart_unfinalized" ] ++ lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) [ # Flakey on aarch64-linux "--skip=sources::exec::tests::test_graceful_shutdown" "--skip=sources::exec::tests::test_run_command_linux" "--skip=topology::test::backpressure::buffer_drop_fan_out" "--skip=topology::test::backpressure::default_fan_out" "--skip=topology::test::backpressure::serial_backpressure" ]; postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' for shell in bash fish zsh; do installShellCompletion --cmd vector --$shell <($out/bin/vector completion $shell) done ''; nativeInstallCheckInputs = [ versionCheckHook ]; doInstallCheck = true; passthru = { tests = nixosTests.vector; updateScript = nix-update-script { }; }; meta = { description = "High-performance observability data pipeline"; homepage = "https://github.com/vectordotdev/vector"; changelog = "https://github.com/vectordotdev/vector/releases/tag/v${finalAttrs.version}"; license = lib.licenses.mpl20; maintainers = with lib.maintainers; [ adamcstephens thoughtpolice happysalada ]; platforms = with lib.platforms; all; mainProgram = "vector"; }; })