Skip to content

feat: add first-class Nix language support - #708

Draft
kubijo wants to merge 5 commits into
biomejs:mainfrom
kubijo:nix-review
Draft

kubijo wants to merge 5 commits into
biomejs:mainfrom
kubijo:nix-review

Conversation

@kubijo

@kubijo kubijo commented Sep 11, 2026

Copy link
Copy Markdown

Summary

Add first-class Nix support using nix-community/tree-sitter-nix at 7799b6c, with parser artifacts generated using Tree-sitter CLI v0.21.0.

This adds:

  • .nix filename detection and language nix
  • Native and WASM parser registration
  • CLI, LSP, target-language, and documentation wiring
  • structural matching for expressions, bindings, nested attrsets, attribute paths, interpolations, dynamic attributes, and function parameters
  • diagnostics and rewrites that preserve unrelated formatting and comments
  • protection against matching source-like text inside comments and strings
  • Useful diagnostics for malformed Nix files

Related grammar PRs:

While those are under review, this draft temporarily points vendor/tree-sitter-gritql to kubijo/tree-sitter-gritql@55043f2, which combines both grammar changes. That review-only commit will be removed and replaced with the canonical merged SHA before this PR is marked ready.

The stack also includes narrow fixes that make CLI test setup and grammar-generation failures reliable for contributors.

Test Plan

  • Nix metavariable grammar corpus: 6 passed
  • Nix language tests: 7 passed
  • Nix structural matching tests: 9 passed
  • Nix CLI apply/check tests: 3 passed
  • LSP tests: passed
  • cargo +1.82.0 fmt -- --check
  • CI-equivalent cargo +1.82.0 clippy ... -D warnings
  • Complete feasible workspace suite with only the live confirm_telemetry_flush test skipped
  • wasm-pack build --target web
  • wasm-tools validate crates/wasm-bindings/wasm_parsers/tree-sitter-nix.wasm

Docs

Updated the target-language reference and documentation language mappings to include Nix.

AI assistance: OpenAI Codex assisted with repository investigation, implementation, parser regeneration, test development, and validation. I reviewed the resulting changes and test output.

Keep an initialized global Grit directory alive for CLI tests so they do not depend on user state. Isolate the remote-pattern module cache and update the Valibot fixture to its maintained repository.
Use the Tree-sitter 0.21 WASM command, honor grammar copy exclusions, and surface generation failures across platforms.
Register Nix for native, CLI, LSP, documentation, and WASM use. Generate a metavariable-aware parser from nix-community/tree-sitter-nix and cover structural matching, diagnostics, rewrites, and filename detection.

Base the GritQL grammar update on canonical Biome main and include the prerequisite snippet-tokenization fix.
Expose attrset and let binding sets as fields so nested bindings participate in structural matching. Accept metavariables in Nix function parameters and cover indented strings, malformed files, and nested constructs.
Point the GritQL grammar submodule at the fork containing the combined prerequisite branches so draft parent CI can initialize before the grammar changes merge. Drop this commit after updating to canonical upstream.
@kubijo
kubijo marked this pull request as draft September 11, 2026 10:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant