1 { lib, buildGoModule, fetchFromGitHub, stdenv, pkg-config, rustPlatform, libiconv, fetchpatch, nixosTests }:
4 libflux_version = "0.194.5";
6 # This is copied from influxdb2 with the required flux version
7 flux = rustPlatform.buildRustPackage rec {
9 version = "v${libflux_version}";
10 src = fetchFromGitHub {
13 rev = "v${libflux_version}";
14 hash = "sha256-XHT/+JMu5q1cPjZT2x/OKEPgxFJcnjrQKqn8w9/Mb3s=";
17 # Fix build on Rust 1.78 (included after v0.195.0)
19 name = "fix-build-on-rust-1.78.patch";
20 url = "https://github.com/influxdata/flux/commit/68c831c40b396f0274f6a9f97d77707c39970b02.patch";
24 hash = "sha256-6LOTgbOCfETNTmshyXgtDZf9y4t/2iqRuVPkz9dYPHc=";
26 ../influxdb2/fix-unsigned-char.patch
28 sourceRoot = "${src.name}/libflux";
29 cargoHash = "sha256-O+t4f4P5291BuyARH6Xf3LejMFEQEBv+qKtyjHRhclA=";
30 nativeBuildInputs = [ rustPlatform.bindgenHook ];
31 buildInputs = lib.optional stdenv.isDarwin libiconv;
34 Version: ${libflux_version}
35 Description: Library for the InfluxData Flux engine
36 Cflags: -I/out/include
37 Libs: -L/out/lib -lflux -lpthread
39 passAsFile = [ "pkgcfg" ];
41 mkdir -p $out/include $out/pkgconfig
42 cp -r $NIX_BUILD_TOP/source/libflux/include/influxdata $out/include
43 substitute $pkgcfgPath $out/pkgconfig/flux.pc \
45 '' + lib.optionalString stdenv.isDarwin ''
46 install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib
54 src = fetchFromGitHub {
58 hash = "sha256-Aibu3yG/D1501Hr2F2qsGvjig14tbEAI+MBfqbxlpg8=";
61 vendorHash = "sha256-AA6uj7PgXjC+IK2ZSwRnYpHS4MFScOROO1BpP+s33IU=";
63 nativeBuildInputs = [ pkg-config ];
65 PKG_CONFIG_PATH = "${flux}/pkgconfig";
67 # Check that libflux is at the right version
69 flux_ver=$(grep github.com/influxdata/flux go.mod | awk '{print $2}')
70 if [ "$flux_ver" != "v${libflux_version}" ]; then
71 echo "go.mod wants libflux $flux_ver, but nix derivation provides ${libflux_version}"
78 ldflags = [ "-s" "-w" "-X main.version=${version}" ];
80 excludedPackages = "test";
82 passthru.tests = { inherit (nixosTests) influxdb; };
85 description = "Open-source distributed time series database";
86 license = licenses.mit;
87 homepage = "https://influxdata.com/";
88 maintainers = with maintainers; [ offline zimbatm ];