tree-sitter: patch out web-ui by default, to drop emscripten
The tree-sitter build closure is pretty lean by default, but the optional web-ui requires emscripten to compile the web interface javascript/wasm code. This is clearly not worth the increase in build closure size, and since emscripten is broken more often than not, let’s patch it out by default. If somebody /really/ needs the web-ui, there is a `webUISupport` flag.
This commit is contained in:
parent
fb875dcf6f
commit
c505e57173
|
@ -2,10 +2,12 @@
|
||||||
, fetchgit, fetchFromGitHub, fetchurl
|
, fetchgit, fetchFromGitHub, fetchurl
|
||||||
, writeShellScript, runCommand, which
|
, writeShellScript, runCommand, which
|
||||||
, rustPlatform, jq, nix-prefetch-git, xe, curl, emscripten
|
, rustPlatform, jq, nix-prefetch-git, xe, curl, emscripten
|
||||||
|
, Security
|
||||||
, callPackage
|
, callPackage
|
||||||
|
|
||||||
, enableShared ? true
|
, enableShared ? true
|
||||||
, enableStatic ? false
|
, enableStatic ? false
|
||||||
, Security
|
, webUISupport ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
# TODO: move to carnix or https://github.com/kolloch/crate2nix
|
# TODO: move to carnix or https://github.com/kolloch/crate2nix
|
||||||
|
@ -54,20 +56,25 @@ in rustPlatform.buildRustPackage {
|
||||||
pname = "tree-sitter";
|
pname = "tree-sitter";
|
||||||
inherit src version cargoSha256;
|
inherit src version cargoSha256;
|
||||||
|
|
||||||
buildInputs = lib.optionals stdenv.isDarwin [ Security ];
|
buildInputs =
|
||||||
|
lib.optionals stdenv.isDarwin [ Security ];
|
||||||
|
nativeBuildInputs =
|
||||||
|
[ which ]
|
||||||
|
++ lib.optionals webUISupport [ emscripten ];
|
||||||
|
|
||||||
nativeBuildInputs = [ emscripten which ];
|
postPatch = lib.optionalString (!webUISupport) ''
|
||||||
|
# remove web interface
|
||||||
postPatch = ''
|
sed -e '/pub mod web_ui/d' \
|
||||||
# needed for the tests
|
-i cli/src/lib.rs
|
||||||
rm -rf test/fixtures/grammars
|
sed -e 's/web_ui,//' \
|
||||||
ln -s ${grammars} test/fixtures/grammars
|
-e 's/web_ui::serve(¤t_dir.*$/println!("ERROR: web-ui is not available in this nixpkgs build; enable the webUISupport"); std::process::exit(1);/' \
|
||||||
|
-i cli/src/main.rs
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Compile web assembly with emscripten. The --debug flag prevents us from
|
# Compile web assembly with emscripten. The --debug flag prevents us from
|
||||||
# minifying the JavaScript; passing it allows us to side-step more Node
|
# minifying the JavaScript; passing it allows us to side-step more Node
|
||||||
# JS dependencies for installation.
|
# JS dependencies for installation.
|
||||||
preBuild = ''
|
preBuild = lib.optionalString webUISupport ''
|
||||||
bash ./script/build-wasm --debug
|
bash ./script/build-wasm --debug
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue