From 773f17e1df61c9cdf0b03d984b89131f03f9754f Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Sun, 16 Jun 2024 18:03:18 +0100 Subject: [PATCH] quickwit: Enable building UI Based on patch by Thomas Cheronneau --- pkgs/servers/search/quickwit/default.nix | 52 ++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/search/quickwit/default.nix b/pkgs/servers/search/quickwit/default.nix index 095bfc679aa4..ece87aa43ae2 100644 --- a/pkgs/servers/search/quickwit/default.nix +++ b/pkgs/servers/search/quickwit/default.nix @@ -7,14 +7,20 @@ , protobuf , rust-jemalloc-sys , Security +, nodejs +, yarn +, fetchYarnDeps +, fixup-yarn-lock }: let pname = "quickwit"; version = "0.8.1"; -in -rustPlatform.buildRustPackage rec { - inherit pname version; + + yarnOfflineCache = fetchYarnDeps { + yarnLock = "${src}/quickwit/quickwit-ui/yarn.lock"; + hash = "sha256-HppK9ycUxCOIagvzCmE+VfcmfMQfPIC8WeWM6WbA6fQ="; + }; src = fetchFromGitHub { owner = "quickwit-oss"; @@ -23,6 +29,41 @@ rustPlatform.buildRustPackage rec { hash = "sha256-B5U9nzXh6kj3/UnQzM3//h4hn9ippWHbeDMcMTP9XfM="; }; + quickwit-ui = stdenv.mkDerivation { + name = "quickwit-ui"; + src = "${src}/quickwit/quickwit-ui"; + + nativeBuildInputs = [ + nodejs + yarn + fixup-yarn-lock + ]; + + configurePhase = '' + export HOME=$(mktemp -d) + ''; + + buildPhase = '' + yarn config --offline set yarn-offline-mirror ${yarnOfflineCache} + fixup-yarn-lock yarn.lock + + yarn install --offline \ + --frozen-lockfile --no-progress \ + --ignore-engines --ignore-scripts + patchShebangs . + + yarn build + ''; + + installPhase = '' + mkdir $out + mv build/* $out + ''; + }; +in +rustPlatform.buildRustPackage rec { + inherit pname version src; + postPatch = '' substituteInPlace ./quickwit-ingest/build.rs \ --replace-fail '.with_protos' '.with_includes(&["."]).with_protos' @@ -34,6 +75,11 @@ rustPlatform.buildRustPackage rec { sourceRoot = "${src.name}/quickwit"; + preBuild = '' + mkdir -p quickwit-ui/build + cp -r ${quickwit-ui}/* quickwit-ui/build + ''; + buildInputs = [ rust-jemalloc-sys ] ++ lib.optionals stdenv.isDarwin [ Security ];