feat: add flake-aware Nix language support#412
Open
BrockLeeBytes wants to merge 6 commits intotirth8205:mainfrom
Open
feat: add flake-aware Nix language support#412BrockLeeBytes wants to merge 6 commits intotirth8205:mainfrom
BrockLeeBytes wants to merge 6 commits intotirth8205:mainfrom
Conversation
dpesch
added a commit
to 11com7/code-review-graph
that referenced
this pull request
May 3, 2026
Adds Nix (.nix) parsing via tree-sitter-nix. Indexes attribute set bindings as Function nodes, emits IMPORTS_FROM edges for flake inputs.*.url strings and import/callPackage applications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
.nixas a supported language in the Tree-sitter parser with flake-aware semantics. No new runtime dependency —tree-sitter-language-packalready ships the Nix grammar.What gets extracted:
attrpath = expr;) becomeFunctionnodes with flattened dotted names (e.g.packages.default,devShells.default). CONTAINS edges wire the file to each top-level binding.flake.nix,inputs.<name>.url = "..."strings (both the flat and the nestedinputs = { nixpkgs.url = "..."; ... };forms) emitIMPORTS_FROMedges targeting the URL.import <path>andcallPackage <path> <args>applications in any.nixfile emitIMPORTS_FROMedges. Relative paths are resolved against the caller's directory (mirrors the Bashsourcehandling); URLs and bare identifiers are preserved as-is.Changes
code_review_graph/parser.py:EXTENSION_TO_LANGUAGE:.nix→nix_CLASS_TYPES/_FUNCTION_TYPES/_IMPORT_TYPES/_CALL_TYPES(pattern matches Elixir/Bash)bindingnodes_extract_nix_constructsmethod + three helpers (_is_nix_flake_file,_nix_attrpath_parts,_extract_nix_flake_input_urls,_extract_nix_import_targets)_do_resolve_module: newnixbranch for relative.nixpath resolutiontests/fixtures/sample.nix,tests/fixtures/sample_module.nix: flake and non-flake fixturestests/test_multilang.py: newTestNixParsingclass (7 tests covering language detection, node language tags, top-level binding flattening, flakeinputs.*.urledges,import/callPackageedges, non-flake negative case, and CONTAINS wiring)CLAUDE.md,README.md,CHANGELOG.md,diagrams/generate_diagrams.py: docs and language-coverage diagram updatedVerification
Automated:
Full suite:
+7 new passes, 0 regressions(the 60 pre-existing failures inTestJuliaParsing/TestGDScriptParsing/test_main'sTestApplyToolFilterare all unrelated to this change — confirmed by running the full suite on HEAD vs.HEAD~3).Test plan
uv run pytest tests/test_multilang.py::TestNixParsing -v— all 7 passuv run pytest tests/ --tb=short -q— no new regressionsuv run ruff check code_review_graph/parser.py— cleanuv run mypy code_review_graph/parser.py --ignore-missing-imports --no-strict-optional— cleanNotes
test_non_flake_file_has_no_input_edges) verifies that theinputs.*.urlbranch only fires when the file basename isflake.nix, so random.urlbindings in NixOS modules don't get misinterpreted as flake inputs.inputs = { nixpkgs.url = "..."; ... };) is necessary — the flat form (inputs.nixpkgs.url = "...";) only covers part of real-world flake usage.