about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikola Knezevic <nikola.knezevic@imc.com>2022-10-19 10:17:28 +0200
committerzowoq <59103226+zowoq@users.noreply.github.com>2022-10-22 14:49:08 +1000
commit711f79539cff7a27999fed09a3d8a0d8dcc1ab26 (patch)
treecb3e93259dd62c49b0431c32e28bca8daf2f8781
parent4f994423305cb598e2d275efd6bb0caa5c895816 (diff)
influxdb: 1.8.10 -> 1.10.0
This change updates the version of influxdb and also makes it compile on
darwin. The issue with darwin was that 1.8 couldn't be compiled using go
1.18. 1.10 can be compiled using the recent go.
-rw-r--r--pkgs/servers/nosql/influxdb/default.nix68
1 files changed, 63 insertions, 5 deletions
diff --git a/pkgs/servers/nosql/influxdb/default.nix b/pkgs/servers/nosql/influxdb/default.nix
index eac918cafa2d7..ea65a759dacfd 100644
--- a/pkgs/servers/nosql/influxdb/default.nix
+++ b/pkgs/servers/nosql/influxdb/default.nix
@@ -1,17 +1,76 @@
-{ lib, buildGoModule, fetchFromGitHub, stdenv }:
+{ lib, buildGoModule, fetchFromGitHub, stdenv, pkg-config, rustPlatform, llvmPackages, libiconv, fetchpatch }:
 
+let
+  libflux_version = "0.170.1";
+
+  # This is copied from influxdb2 with flux version matching the needed by thi
+  flux = rustPlatform.buildRustPackage {
+    pname = "libflux";
+    version = "v${libflux_version}";
+    src = fetchFromGitHub {
+      owner = "influxdata";
+      repo = "flux";
+      rev = "v${libflux_version}";
+      sha256 = "sha256-P3SpleOVbL+nGWdscwjj9yWqRdck/9JsAwuJtGOO7N8=";
+    };
+    patches = [
+      # https://github.com/influxdata/flux/pull/5273
+      # fix compile error with Rust 1.64
+      (fetchpatch {
+        url = "https://github.com/influxdata/flux/commit/20ca62138a0669f2760dd469ca41fc333e04b8f2.patch";
+        stripLen = 2;
+        extraPrefix = "";
+        sha256 = "sha256-Fb4CuH9ZvrPha249dmLLI8MqSNQRKqKPxPbw2pjqwfY=";
+      })
+    ];
+    sourceRoot = "source/libflux";
+    cargoSha256 = "sha256-kYiZ5ZRiFHRf1RQeeUGjIhnEkTvhNSZ0t4tidpRIDyk=";
+    nativeBuildInputs = [ llvmPackages.libclang ];
+    buildInputs = lib.optional stdenv.isDarwin libiconv;
+    LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
+    pkgcfg = ''
+      Name: flux
+      Version: ${libflux_version}
+      Description: Library for the InfluxData Flux engine
+      Cflags: -I/out/include
+      Libs: -L/out/lib -lflux -ldl -lpthread
+    '';
+    passAsFile = [ "pkgcfg" ];
+    postInstall = ''
+      mkdir -p $out/include $out/pkgconfig
+      cp -r $NIX_BUILD_TOP/source/libflux/include/influxdata $out/include
+      substitute $pkgcfgPath $out/pkgconfig/flux.pc \
+        --replace /out $out
+    '' + lib.optionalString stdenv.isDarwin ''
+      install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib
+    '';
+  };
+in
 buildGoModule rec {
   pname = "influxdb";
-  version = "1.8.10";
+  version = "1.10.0";
 
   src = fetchFromGitHub {
     owner = "influxdata";
     repo = pname;
     rev = "v${version}";
-    sha256 = "sha256-PErAxRpSi1Kk6IpEAhsUSxCGYeY4p6bbhwLdbRB0M00=";
+    sha256 = "sha256-BMHR9EdYC+8oA0he7emzBRmNnHn15nO/5NqsLcr+R0k=";
   };
 
-  vendorSha256 = "sha256-jgAbEWXL1LYRN7ud9ij0Z1KBGHPZ0sRq78tsK92ob8k=";
+  vendorSha256 = "sha256-AY04cmfg7vbrWR4+LBuCFYqBgQJBXlPpO+2oj0qqjM4=";
+
+  nativeBuildInputs = [ pkg-config ];
+
+  PKG_CONFIG_PATH = "${flux}/pkgconfig";
+
+  # Check that libflux is at the right version
+  preBuild = ''
+    flux_ver=$(grep github.com/influxdata/flux go.mod | awk '{print $2}')
+    if [ "$flux_ver" != "v${libflux_version}" ]; then
+      echo "go.mod wants libflux $flux_ver, but nix derivation provides ${libflux_version}"
+      exit 1
+    fi
+  '';
 
   doCheck = false;
 
@@ -24,6 +83,5 @@ buildGoModule rec {
     license = licenses.mit;
     homepage = "https://influxdata.com/";
     maintainers = with maintainers; [ offline zimbatm ];
-    broken = stdenv.isDarwin; # build fails with go > 1.17
   };
 }