Skip to content

Add Nix language support (outline + semantic + AST) #492

Open

Description

@kido5217

Description

Add LangId::Nix with the outline + semantic + AST columns. Nix is code-shaped and AFT-relevant (flakes, modules, home-manager configs), has a maintained tree-sitter grammar, and — per #85's admission rule — a publishable one.

Proposed scope

Column Row
Outline tree-sitter-nix (pin: numtide @ rev — see provenance below); extractor likely fits the queryless tree-walk lane (TOML/YAML/JSON precedent) over binding / let_expression / formals nodes; nested attrpaths (foo.bar = …) as dotted symbols
Edit free (indent default 2-space; formatter.nix config key like every non-builtin language)
AST AstGrepLang::Nix + plugin enum widening
Semantic "nix" in is_semantic_indexed_extension
Imports unsupported by design — Nix import is a value expression; the None arm, same as Zig/Bash
Refactor unsupported by design — functions are expressions, not declarations
Callgraph empty in the first PR; lexical call edges + an import-path module graph look feasible as a follow-up — callPackage/module-system edges are evaluator-only territory
LSP no change needed: nixd already registered (PATH-only)

Why the grammar is a safe dep (measured):

  • ABI: both nix-community 0.3.0 (crates.io, ~2.9 M downloads) and numtide master build & load against tree-sitter 0.26; numtide is ABI 15 native.
  • Latency: 24 ms full parse of the 2 120-line file from the perf report (tree-sitter-nix #142 — its 3 s figure is nvim buffer-load wall clock, not parsing); 10 703-line all-packages.nix: 90–126 ms.
  • Coverage: attrsets / attrpaths / inherit (e) / dynamic names / indented strings / formals / select or all clean against Nix 2.34 ground truth; numtide additionally closes nix-community's two open gaps (pipe |> tree-sitter-nix#159, empty inherit; tree-sitter-nix#162).
  • Provenance: numtide is the active line (last grammar commit 2026-10-08; the nix-community repo's 2026 commits are bot bumps, its grammar bugs untriaged since 2025). Numtide's README ("Release cadence") states a crates.io publish under a numtide-scoped name is planned — that's the pin we'd prefer once it lands. If it never does, a cortexkit-published fork is the SCSS playbook (cortexkit-tree-sitter-scss) and we'd take that happily.
  • Numtide's one regression vs nix-community is stricter ERROR recovery on or-as-identifier forms that Nix itself deprecates; symbol structure survives it.

Effort estimate: outline + semantic + AST ≈ 300–500 lines + one integration test + README row — same band as CUDA (+252) / Pascal (+699). Happy to file the PR behind design-approved; equally happy if the fleet ships it first — Nix users just want the row.

Use case

A NixOS host with nixpkgs-scale configs is exactly the environment where AFT's outline/semantic tools would earn their keep on .nix files — flake.nix, module trees, home-manager configs are read constantly by agents and have no symbol-level navigation today.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions