From 4852095139df567fe439270420b571fe35516e02 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Wed, 3 Apr 2024 12:36:20 -0700 Subject: [PATCH] tree-sitter: embed path to `emcc` so `tree-sitter build --wasm` works --- .../tools/parsing/tree-sitter/default.nix | 8 ++++++++ .../tools/parsing/tree-sitter/fix-paths.patch | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 pkgs/development/tools/parsing/tree-sitter/fix-paths.patch diff --git a/pkgs/development/tools/parsing/tree-sitter/default.nix b/pkgs/development/tools/parsing/tree-sitter/default.nix index d30a427ea8be..97554e53de20 100644 --- a/pkgs/development/tools/parsing/tree-sitter/default.nix +++ b/pkgs/development/tools/parsing/tree-sitter/default.nix @@ -9,6 +9,7 @@ , Security , callPackage , linkFarm +, substitute , CoreServices , enableShared ? !stdenv.hostPlatform.isStatic , enableStatic ? stdenv.hostPlatform.isStatic @@ -117,6 +118,13 @@ rustPlatform.buildRustPackage { [ which ] ++ lib.optionals webUISupport [ emscripten ]; + patches = lib.optionals webUISupport [ + (substitute { + src = ./fix-paths.patch; + substitutions = [ "--subst-var-by" "emcc" "${emscripten}/bin/emcc" ]; + }) + ]; + postPatch = lib.optionalString (!webUISupport) '' # remove web interface sed -e '/pub mod playground/d' \ diff --git a/pkgs/development/tools/parsing/tree-sitter/fix-paths.patch b/pkgs/development/tools/parsing/tree-sitter/fix-paths.patch new file mode 100644 index 000000000000..6023a5934c8f --- /dev/null +++ b/pkgs/development/tools/parsing/tree-sitter/fix-paths.patch @@ -0,0 +1,13 @@ +diff --git a/cli/loader/src/lib.rs b/cli/loader/src/lib.rs +index 9c1d8dfc..a5cfc74c 100644 +--- a/cli/loader/src/lib.rs ++++ b/cli/loader/src/lib.rs +@@ -747,7 +747,7 @@ impl Loader { + Podman, + } + +- let emcc_name = if cfg!(windows) { "emcc.bat" } else { "emcc" }; ++ let emcc_name = if cfg!(windows) { "emcc.bat" } else { "@emcc@" }; + + // Order of preference: emscripten > docker > podman > error + let source = if !force_docker && Command::new(emcc_name).output().is_ok() {