Add Nix Language Support#1048
Conversation
|
Thanks for the Nix support! The extractor logic is solid — the Use Every other language in graphify follows the Add a fixture file Tests use Minor: duplicate branch in if path_str.startswith("./") or path_str.startswith("../"):
resolved_path = (path.parent / path_str).resolve()
else:
resolved_path = (path.parent / path_str).resolve() # identicalBoth arms do the same thing — the
Adding it to Once these are addressed this is ready to land. |
Add a fixture file for nix, dedupe branch in `_add_import_edge` Make `tree-sitter-nix` a soft dependency.
Addressed all 4 issues raised, following the example of how Lua, Swift and C# is handled. Deconflicted with Ready for a second pass @safishamsi. Thank you for your time! |
Issue: #1049
This PR adds native Nix (
.nix) parser and AST extractor support tographify. This enables the tool to discover.nixfiles, parse them usingtree-sitter-nix, extract code symbols (let-bindings, attributes, recursive attribute sets), and map relationships (such as relative imports and list-based module declarations) into the knowledge graph.Key Changes
Parser & Extractor:
tree-sitter-nixto project dependencies inpyproject.toml.extract_nixingraphify/extract.pyto parse Nix expressions (bindings,importstatements, recursiverec { ... }sets, and list attributes likeimports = [ ... ]).AST Build, Scoping, and Presentation:
"nix"language family indetect.py,build.py,analyze.py,symbol_resolution.py, andcallflow_html.pyto prevent false-positive cross-language references and format Nix module labels and HTML descriptions correctly.Verification:
test_nix_extractionintests/test_languages.py.Manual Verification
Tested against a couple of nix based projects I already knew deep and wide.
To manually verify the changes against a Nix configuration project:
pip install -e .graphify-out/graph.htmlandGRAPH_REPORT.mdshow the extracted Nix attributes and import edges cleanly.