diff --git a/pkgs/development/tools/parsing/tree-sitter/default.nix b/pkgs/development/tools/parsing/tree-sitter/default.nix index 37811943a6de..57c12cce93ea 100644 --- a/pkgs/development/tools/parsing/tree-sitter/default.nix +++ b/pkgs/development/tools/parsing/tree-sitter/default.nix @@ -2,10 +2,12 @@ , fetchgit, fetchFromGitHub, fetchurl , writeShellScript, runCommand, which , rustPlatform, jq, nix-prefetch-git, xe, curl, emscripten +, Security , callPackage + , enableShared ? true , enableStatic ? false -, Security +, webUISupport ? false }: # TODO: move to carnix or https://github.com/kolloch/crate2nix @@ -54,20 +56,25 @@ in rustPlatform.buildRustPackage { pname = "tree-sitter"; 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 = '' - # needed for the tests - rm -rf test/fixtures/grammars - ln -s ${grammars} test/fixtures/grammars + postPatch = lib.optionalString (!webUISupport) '' + # remove web interface + sed -e '/pub mod web_ui/d' \ + -i cli/src/lib.rs + sed -e 's/web_ui,//' \ + -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 # minifying the JavaScript; passing it allows us to side-step more Node # JS dependencies for installation. - preBuild = '' + preBuild = lib.optionalString webUISupport '' bash ./script/build-wasm --debug '';