From 56b70351dd1c5fad39c782f3cc86727ba7f23588 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Jan 2026 12:57:54 -0500 Subject: [PATCH] llama-cpp: build webui from source Upstream commits it as a static file to the repo. This impedes applying patches to the webui in the build here. npmDepsHash and patches are done this way to make it easier to use overrideAttrs (otherwise it is nigh-impossible to get it correct). --- pkgs/by-name/ll/llama-cpp/package.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkgs/by-name/ll/llama-cpp/package.nix b/pkgs/by-name/ll/llama-cpp/package.nix index 93235e8127f9..ae51615fc4b4 100644 --- a/pkgs/by-name/ll/llama-cpp/package.nix +++ b/pkgs/by-name/ll/llama-cpp/package.nix @@ -27,6 +27,10 @@ ], blas, + fetchNpmDeps, + nodejs, + npmHooks, + pkg-config, metalSupport ? stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 && !openclSupport, vulkanSupport ? false, @@ -88,10 +92,18 @@ effectiveStdenv.mkDerivation (finalAttrs: { ''; }; + patches = [ ]; + + postPatch = '' + rm tools/server/public/index.html.gz + ''; + nativeBuildInputs = [ cmake installShellFiles ninja + nodejs + npmHooks.npmConfigHook pkg-config ] ++ optionals cudaSupport [ @@ -107,8 +119,22 @@ effectiveStdenv.mkDerivation (finalAttrs: { ++ optionals vulkanSupport vulkanBuildInputs ++ [ openssl ]; + npmRoot = "tools/server/webui"; + npmDepsHash = "sha256-m1boNqwMELdpHbV/jYK3hpf2vP1S/KSAf32wVKQGyFo="; + npmDeps = fetchNpmDeps { + name = "${finalAttrs.pname}-${finalAttrs.version}-npm-deps"; + inherit (finalAttrs) src patches; + preBuild = '' + pushd ${finalAttrs.npmRoot} + ''; + hash = finalAttrs.npmDepsHash; + }; + preConfigure = '' prependToVar cmakeFlags "-DLLAMA_BUILD_COMMIT:STRING=$(cat COMMIT)" + pushd ${finalAttrs.npmRoot} + npm run build + popd ''; cmakeFlags = [