Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 141 lines 3.7 kB view raw
1{ 2 buildGoModule, 3 fetchFromGitHub, 4 fetchurl, 5 fetchpatch, 6 go-bindata, 7 lib, 8 perl, 9 pkg-config, 10 rustPlatform, 11 stdenv, 12 libiconv, 13 nixosTests, 14}: 15 16let 17 version = "2.7.12"; 18 ui_version = "OSS-v2.7.12"; 19 libflux_version = "0.196.1"; 20 21 src = fetchFromGitHub { 22 owner = "influxdata"; 23 repo = "influxdb"; 24 rev = "v${version}"; 25 hash = "sha256-FwvcKxCozMqJulDDCFDgp7MYJwMq/9XZ6g2q2lIgFc0="; 26 }; 27 28 ui = fetchurl { 29 url = "https://github.com/influxdata/ui/releases/download/${ui_version}/build.tar.gz"; 30 hash = "sha256-aC+GYMaxYKkY9GMaeRx22hQ3xi3kfWpaTLC9ajqOaAA="; 31 }; 32 33 flux = rustPlatform.buildRustPackage { 34 pname = "libflux"; 35 version = libflux_version; 36 src = fetchFromGitHub { 37 owner = "influxdata"; 38 repo = "flux"; 39 rev = "v${libflux_version}"; 40 hash = "sha256-935aN2SxfNZvpG90rXuqZ2OTpSGLgiBDbZsBoG0WUvU="; 41 }; 42 patches = [ 43 # https://github.com/influxdata/flux/pull/5542 44 ./fix-unsigned-char.patch 45 ]; 46 # Don't fail on missing code documentation 47 postPatch = '' 48 substituteInPlace flux-core/src/lib.rs \ 49 --replace-fail "deny(warnings, missing_docs))]" "deny(warnings))]" 50 ''; 51 sourceRoot = "${src.name}/libflux"; 52 53 cargoHash = "sha256-A6j/lb47Ob+Po8r1yvqBXDVP0Hf7cNz8WFZqiVUJj+Y="; 54 nativeBuildInputs = [ rustPlatform.bindgenHook ]; 55 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libiconv; 56 pkgcfg = '' 57 Name: flux 58 Version: ${libflux_version} 59 Description: Library for the InfluxData Flux engine 60 Cflags: -I/out/include 61 Libs: -L/out/lib -lflux -lpthread 62 ''; 63 passAsFile = [ "pkgcfg" ]; 64 postInstall = '' 65 mkdir -p $out/include $out/pkgconfig 66 cp -r $NIX_BUILD_TOP/source/libflux/include/influxdata $out/include 67 substitute $pkgcfgPath $out/pkgconfig/flux.pc \ 68 --replace-fail /out $out 69 '' 70 + lib.optionalString stdenv.hostPlatform.isDarwin '' 71 install_name_tool -id $out/lib/libflux.dylib $out/lib/libflux.dylib 72 ''; 73 }; 74in 75buildGoModule { 76 pname = "influxdb"; 77 version = version; 78 inherit src; 79 80 nativeBuildInputs = [ 81 go-bindata 82 pkg-config 83 perl 84 ]; 85 86 vendorHash = "sha256-B4w8+UaewujKVr98MFhRh2c6UMOdB+TE/mOT+cy2pHk="; 87 subPackages = [ 88 "cmd/influxd" 89 "cmd/telemetryd" 90 ]; 91 92 PKG_CONFIG_PATH = "${flux}/pkgconfig"; 93 94 postPatch = '' 95 # use go-bindata from environment 96 substituteInPlace static/static.go \ 97 --replace-fail 'go run github.com/kevinburke/go-bindata/' "" 98 ''; 99 100 # Check that libflux and the UI are at the right version, and embed 101 # the UI assets into the Go source tree. 102 preBuild = '' 103 ( 104 flux_ver=$(grep github.com/influxdata/flux go.mod | awk '{print $2}') 105 if [ "$flux_ver" != "v${libflux_version}" ]; then 106 echo "go.mod wants libflux $flux_ver, but nix derivation provides ${libflux_version}" 107 exit 1 108 fi 109 110 ui_ver=$(egrep 'UI_RELEASE=".*"' scripts/fetch-ui-assets.sh | cut -d'"' -f2) 111 if [ "$ui_ver" != "${ui_version}" ]; then 112 echo "scripts/fetch-ui-assets.sh wants UI $ui_ver, but nix derivation provides ${ui_version}" 113 exit 1 114 fi 115 ) 116 117 mkdir -p static/data 118 tar -xzf ${ui} -C static/data 119 pushd static 120 go generate 121 popd 122 ''; 123 124 tags = [ "assets" ]; 125 126 ldflags = [ 127 "-X main.commit=v${version}" 128 "-X main.version=${version}" 129 ]; 130 131 passthru.tests = { 132 inherit (nixosTests) influxdb2; 133 }; 134 135 meta = with lib; { 136 description = "Open-source distributed time series database"; 137 license = licenses.mit; 138 homepage = "https://influxdata.com/"; 139 maintainers = with maintainers; [ abbradar ]; 140 }; 141}