mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-07-23 11:10:55 -05:00
nix : add nix-nodejs facilities to build Web UI (#23846)
* nix: add nix-nodejs facilities to build Web UI Build the Web UI locally using standard Nix systems for building NodeJS packages. - Create derivation for the web UI - npm dependencies are imported via buildNodeModules. Does not require setting any shasum. - Copy build artifacts to the correct folders. - Prevents having to download from huggingface.co Fixes #23067 * nix: simplify webui derivation using LLAMA_UI_OUT_DIR - Move npm build to installPhase with LLAMA_UI_OUT_DIR=$out to write output directly to the Nix store - Copy built assets to tools/ui/dist (source tree) instead of build/tools/ui/dist so CMake's copy_src_dist() finds them
This commit is contained in:
committed by
GitHub
parent
27d9ed8397
commit
5aa3a64596
@@ -3,6 +3,7 @@
|
|||||||
glibc,
|
glibc,
|
||||||
config,
|
config,
|
||||||
stdenv,
|
stdenv,
|
||||||
|
stdenvNoCC,
|
||||||
runCommand,
|
runCommand,
|
||||||
cmake,
|
cmake,
|
||||||
ninja,
|
ninja,
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
openssl,
|
openssl,
|
||||||
shaderc,
|
shaderc,
|
||||||
spirv-headers,
|
spirv-headers,
|
||||||
|
nodejs,
|
||||||
|
importNpmLock,
|
||||||
useBlas ?
|
useBlas ?
|
||||||
builtins.all (x: !x) [
|
builtins.all (x: !x) [
|
||||||
useCuda
|
useCuda
|
||||||
@@ -130,7 +133,31 @@ effectiveStdenv.mkDerivation (finalAttrs: {
|
|||||||
src = lib.cleanSource ../../.;
|
src = lib.cleanSource ../../.;
|
||||||
};
|
};
|
||||||
|
|
||||||
postPatch = ''
|
# Builds the webui locally, taking care not to require updating any sha256 hash.
|
||||||
|
webui = stdenvNoCC.mkDerivation {
|
||||||
|
pname = "webui";
|
||||||
|
version = llamaVersion;
|
||||||
|
src = lib.cleanSource ../../tools/ui;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
nodejs
|
||||||
|
importNpmLock.linkNodeModulesHook
|
||||||
|
];
|
||||||
|
|
||||||
|
# no sha256 required when using buildNodeModules
|
||||||
|
npmDeps = importNpmLock.buildNodeModules {
|
||||||
|
npmRoot = ../../tools/ui;
|
||||||
|
inherit nodejs;
|
||||||
|
};
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
LLAMA_UI_OUT_DIR=$out npm run build --offline
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
postPatch = lib.optionalString useWebUi ''
|
||||||
|
cp -r ${finalAttrs.webui} tools/ui/dist
|
||||||
|
chmod -R u+w tools/ui/dist
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# With PR#6015 https://github.com/ggml-org/llama.cpp/pull/6015,
|
# With PR#6015 https://github.com/ggml-org/llama.cpp/pull/6015,
|
||||||
|
|||||||
Reference in New Issue
Block a user