Running nixpkgs-update (https://github.com/NixOS/infra/blob/main/non-critical-infra/modules/nixpkgs-update/README.md) with UPDATE_INFO: tree-sitter 0.26.11 -> 0.27.1 https://github.com/tree-sitter/tree-sitter/releases attrpath: tree-sitter Checking auto update branch... [version] [version] generic version rewriter does not support multiple hashes [rustCrateVersion] [rustCrateVersion] skipping because derivation has updateScript [golangModuleVersion] [golangModuleVersion] Not a buildGoModule package with vendorHash [npmDepsVersion] [npmDepsVersion] No npmDepsHash [updateScript] [updateScript] Success [updateScript] this derivation will be built: /nix/store/hbpxrl1pnynvq7cmgp7xr6xjg3xa21jw-packages.json.drv building '/nix/store/hbpxrl1pnynvq7cmgp7xr6xjg3xa21jw-packages.json.drv'... structuredAttrs is enabled Going to be running update for following packages: - tree-sitter-0.26.11 Press Enter key to continue... Running update for: Enqueuing group of 1 packages - tree-sitter-0.26.11: UPDATING ... - tree-sitter-0.26.11: DONE. Packages updated! Diff after rewrites: diff --git a/pkgs/by-name/tr/tree-sitter/package.nix b/pkgs/by-name/tr/tree-sitter/package.nix index ebd2c362f222..884292e8249c 100644 --- a/pkgs/by-name/tr/tree-sitter/package.nix +++ b/pkgs/by-name/tr/tree-sitter/package.nix @@ -135,17 +135,17 @@ let in rustPlatform.buildRustPackage (finalAttrs: { pname = "tree-sitter"; - version = "0.26.11"; + version = "0.27.1"; src = fetchFromGitHub { owner = "tree-sitter"; repo = "tree-sitter"; tag = "v${finalAttrs.version}"; - hash = "sha256-YXnmVM90sEH8kqgqCygpeCAyvggMIsv+oXi0SJOvMRM="; + hash = "sha256-KbPqA6pfplWRUtwRgbNXUF7aivj/n4shJqWbjNO93nQ="; fetchSubmodules = true; }; - cargoHash = "sha256-kHDjPRhBUYlxLWYSv6cn6U1QDIWwCgHeIz2A5yCi1yo="; + cargoHash = "sha256-GbW/qFq8X0UNi9LIepTIAKSAqCXM/gdy6XV6s5YO8r0="; cargoBuildFeatures = lib.optionals wasmSupport [ "wasm" ]; No auto update branch exists Old version 0.26.11" not present in staging derivation file with contents: { lib, stdenv, config, newScope, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchFromCodeberg, fetchpatch, nix-update-script, which, rustPlatform, runCommand, emscripten, openssl, pkg-config, callPackage, linkFarm, substitute, installShellFiles, buildPackages, cmake, validatePkgConfig, # dependencies for wasmSupport wasmtime_48, binaryen, llvmPackages, makeWrapper, pkgsCross, symlinkJoin, enableShared ? !stdenv.hostPlatform.isStatic, enableStatic ? stdenv.hostPlatform.isStatic, wasmSupport ? false, webUISupport ? false, }: let /** Build a parser grammar and put the resulting shared object in `$out/parser`. # Example ```nix tree-sitter-foo = pkgs.tree-sitter.buildGrammar { language = "foo"; version = "0.42.0"; src = fetchFromGitHub { ... }; }; ``` */ buildGrammar = callPackage ./grammars/build-grammar.nix { }; /** Attrset of grammar sources. Values are of the form { language, version, src }. These may be referenced directly by other areas of the tree-sitter ecosystem in nixpkgs. Src will contain all language bindings provided by the upstream grammar. Use pkgs.tree-sitter.grammars. to access. */ grammars = import ./grammars { inherit lib nix-update-script fetchFromGitHub fetchFromGitLab fetchFromSourcehut fetchFromCodeberg fetchpatch stdenv ; }; /** Attrset of compiled grammars. Compiled grammars contain the pre-built shared library and any queries from the grammar source. Use pkgs.tree-sitter-grammars. to access. */ builtGrammars = lib.mapAttrs (_: lib.makeOverridable buildGrammar) grammars; hasTreeSitterPrefix = lib.hasPrefix "tree-sitter-"; grammarAliases = import ./grammars/aliases.nix { inherit lib; }; grammarDerivationsFrom = lib.filterAttrs ( name: value: hasTreeSitterPrefix name && lib.isDerivation value ); removeTreesitterPrefix = lib.strings.removePrefix "tree-sitter-"; removeGrammarSuffix = lib.strings.removeSuffix "-grammar"; replaceHyphens = lib.strings.replaceStrings [ "-" ] [ "_" ]; mkGrammarLinkFarm = grammars: linkFarm "grammars" ( map ( drv: let name = lib.strings.getName drv; in { name = (replaceHyphens (removeTreesitterPrefix (removeGrammarSuffix name))) + ".so"; path = "${drv}/parser"; } ) grammars ); /** Extensible package set of compiled tree-sitter grammars. Exposed as `pkgs.tree-sitter-grammars` and `pkgs.tree-sitter.grammarsScope`. Customize with `.overrideScope`; overrides propagate to every consumer that reads the scope, including the grammar-only views below (which the `pkgs.tree-sitter` passthru re-exports so there is a single source of truth): `.derivations` attrset of every grammar derivation `.allGrammars` list of non-broken grammar derivations `.withPlugins` build a grammar link farm The scope also carries package-set helpers (`callPackage`, `overrideScope`, …) alongside the grammars, so prefer one of the views above when iterating. */ grammarsScope = lib.makeScope newScope ( self: builtGrammars // lib.optionalAttrs config.allowAliases (grammarAliases self builtGrammars) // { derivations = grammarDerivationsFrom self; allGrammars = lib.filter (p: !(p.meta.broken or false)) ( lib.attrValues (grammarDerivationsFrom self) ); withPlugins = grammarFn: mkGrammarLinkFarm (grammarFn (grammarDerivationsFrom self)); } ); isWasi = stdenv.hostPlatform.isWasi; # create a `TREE_SITTER_WASI_SDK_PATH` environment where # `clang -> wasm32-unknown-wasip1-clang` so tree-sitter can find it wasiCC = pkgsCross.wasi32.stdenv.cc; wasiSdk = symlinkJoin { name = "wasi-sdk"; paths = [ wasiCC ]; postBuild = '' ln -s ${wasiCC.targetPrefix}clang $out/bin/clang ''; }; in rustPlatform.buildRustPackage (finalAttrs: { pname = "tree-sitter"; version = "0.27.1"; __structuredAttrs = true; src = fetchFromGitHub { owner = "tree-sitter"; repo = "tree-sitter"; tag = "v${finalAttrs.version}"; hash = "sha256-KbPqA6pfplWRUtwRgbNXUF7aivj/n4shJqWbjNO93nQ="; fetchSubmodules = true; }; cargoHash = "sha256-GbW/qFq8X0UNi9LIepTIAKSAqCXM/gdy6XV6s5YO8r0="; cargoBuildFeatures = lib.optionals wasmSupport [ "wasm" ]; outputs = [ "out" "dev" "lib" ]; buildInputs = [ installShellFiles ] ++ lib.optionals wasmSupport [ wasmtime_48 ] ++ lib.optionals webUISupport [ openssl ]; nativeBuildInputs = [ rustPlatform.bindgenHook validatePkgConfig which ] ++ lib.optionals wasmSupport [ cmake makeWrapper ] ++ lib.optionals webUISupport [ emscripten pkg-config ]; patches = lib.optionals (!webUISupport) [ (substitute { src = ./remove-web-interface.patch; }) (fetchpatch { name = "feat: allow `-` in grammar names"; url = "https://github.com/tree-sitter/tree-sitter/commit/7d3c32125379c1dc02f47277bcd4eceaac299bdb.diff"; hash = "sha256-ZNjdNateHVHDy0/txlAW8TUdz+DVxLKXpw8ojZbIQS8="; }) ]; postPatch = # tree-sitter tries to concatenate $libdir/$includedir to $prefix, # having multiple outputs on different paths requires patching this. '' substituteInPlace lib/tree-sitter.pc.in \ --replace-fail 'libdir=''${prefix}/@CMAKE_INSTALL_LIBDIR@' 'libdir=@CMAKE_INSTALL_FULL_LIBDIR@' \ --replace-fail 'includedir=''${prefix}/@CMAKE_INSTALL_INCLUDEDIR@' 'includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@' substituteInPlace ./Makefile \ --replace-fail 's|@CMAKE_INSTALL_LIBDIR@|$(LIBDIR:$(PREFIX)/%=%)|' 's|@CMAKE_INSTALL_FULL_LIBDIR@|$(LIBDIR)|' \ --replace-fail 's|@CMAKE_INSTALL_INCLUDEDIR@|$(INCLUDEDIR:$(PREFIX)/%=%)|' 's|@CMAKE_INSTALL_FULL_INCLUDEDIR@|$(INCLUDEDIR)|' '' + lib.optionalString webUISupport '' substituteInPlace crates/xtask/src/build_wasm.rs \ --replace-fail 'let emcc_name = if cfg!(windows) { "emcc.bat" } else { "emcc" };' 'let emcc_name = "${lib.getExe' emscripten "emcc"}";' '' # when building on static platforms: # 1. remove the `libtree-sitter.$(SOEXT)` step from `all` # 2. remove references to shared object files in the Makefile + lib.optionalString stdenv.hostPlatform.isStatic '' substituteInPlace ./Makefile \ --replace-fail 'all: libtree-sitter.a libtree-sitter.$(SOEXT) tree-sitter.pc' 'all: libtree-sitter.a tree-sitter.pc' sed -i '/^install:/,/^uninstall:/ { /$(SOEXT/d; }' ./Makefile '' # rquickjs-sys passes the raw rust target to clang, which does not know riscv64gc + lib.optionalString stdenv.hostPlatform.isRiscV64 '' substituteInPlace $cargoDepsCopy/source-*/rquickjs-sys-*/build.rs \ --replace-fail \ 'let mut cflags = vec![format!("--target={}", target)];' \ 'let mut cflags = vec![format!("--target={}", target.replace("riscv64gc", "riscv64"))];' ''; # The Makefile install can't enable the wasm feature. cmakeFlags = lib.optionals wasmSupport [ (lib.cmakeBool "TREE_SITTER_FEATURE_WASM" true) (lib.cmakeFeature "WASMTIME_INCLUDE_DIR" "${lib.getDev wasmtime_48}/include") (lib.cmakeFeature "WASMTIME_LIBRARY" "${lib.getLib wasmtime_48}/lib/libwasmtime${stdenv.hostPlatform.extensions.library}") (lib.cmakeFeature "CMAKE_INSTALL_FULL_INCLUDEDIR" "${placeholder "dev"}/include") (lib.cmakeFeature "CMAKE_INSTALL_FULL_LIBDIR" "${placeholder "lib"}/lib") ]; # 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 = lib.optionalString webUISupport '' mkdir -p .emscriptencache export EM_CACHE=$(pwd)/.emscriptencache cargo run --package xtask -- build-wasm --debug ''; postInstall = '' make install PREFIX=$out LIBDIR=$lib/lib INCLUDEDIR=$dev/include '' # supply the nix paths for the Wasi SDK & `wasm-opt`: https://tree-sitter.github.io/tree-sitter/6-contributing.html#wasm-stdlib # lld is required for the linker phase in `tree-sitter build --wasm` + lib.optionalString wasmSupport '' cmake --install $cmakeBuildDir wrapProgram $out/bin/tree-sitter \ --set-default TREE_SITTER_BINARYEN_PATH "${binaryen}" \ --set-default TREE_SITTER_WASI_SDK_PATH "${wasiSdk}" \ --prefix PATH : "${lib.makeBinPath [ llvmPackages.lld ]}" '' + '' ${lib.optionalString (!enableShared) "rm -f $lib/lib/*.so{,.*}"} ${lib.optionalString (!enableStatic) "rm -f $lib/lib/*.a"} mv docs/src/assets/schemas/config.schema.json $out/ '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' installShellCompletion --cmd tree-sitter \ --bash <("$out/bin/tree-sitter" complete --shell bash) \ --zsh <("$out/bin/tree-sitter" complete --shell zsh) \ --fish <("$out/bin/tree-sitter" complete --shell fish) '' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' installShellCompletion --cmd tree-sitter \ --bash "${buildPackages.tree-sitter}"/share/bash-completion/completions/*.bash \ --zsh "${buildPackages.tree-sitter}"/share/zsh/site-functions/* \ --fish "${buildPackages.tree-sitter}"/share/fish/*/* ''; # test result: FAILED. 120 passed; 13 failed; 0 ignored; 0 measured; 0 filtered out doCheck = false; # CMake builds libtree-sitter with wasm support; cargo still builds the CLI. ${if wasmSupport then "configurePhase" else null} = '' cmakeConfigurePhase cd .. ''; ${if wasmSupport then "postBuild" else null} = '' cmake --build $cmakeBuildDir ''; passthru = { inherit buildGrammar builtGrammars grammars grammarsScope ; # Keep legacy `pkgs.tree-sitter` views wired to the overridable scope. inherit (grammarsScope) allGrammars withPlugins; updateScript = nix-update-script { }; tests = { # make sure all grammars build builtGrammars = lib.recurseIntoAttrs builtGrammars; } // lib.optionalAttrs isWasi { wasmGrammar = let grammar = builtGrammars.tree-sitter-nix; in runCommand "tree-sitter-wasm-grammar-test" { } '' test -f ${grammar}/parser.wasm # WebAssembly binaries start with "\0asm". test "$(od -An -tx1 -N4 ${grammar}/parser.wasm | tr -d ' \n')" = "0061736d" test ! -e ${grammar}/parser touch $out ''; }; }; meta = { homepage = "https://github.com/tree-sitter/tree-sitter"; description = "Parser generator tool and an incremental parsing library"; mainProgram = "tree-sitter"; changelog = "https://github.com/tree-sitter/tree-sitter/releases/tag/v${finalAttrs.version}"; longDescription = '' Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited. Tree-sitter aims to be: * General enough to parse any programming language * Fast enough to parse on every keystroke in a text editor * Robust enough to provide useful results even in the presence of syntax errors * Dependency-free so that the runtime library (which is written in pure C) can be embedded in any application ''; license = lib.licenses.mit; maintainers = with lib.maintainers; [ uncenter amaanq ]; }; })