Skip to content

feat(inlay-hint): implement deterministic definition tracing for pkgs#846

Draft
Malix-Labs wants to merge 1 commit into
nix-community:mainfrom
Malix-Labs:issue/835
Draft

feat(inlay-hint): implement deterministic definition tracing for pkgs#846
Malix-Labs wants to merge 1 commit into
nix-community:mainfrom
Malix-Labs:issue/835

Conversation

@Malix-Labs

Copy link
Copy Markdown
Contributor

FIXES: #835

This PR implements deterministic definition tracing for the pkgs scope to resolve issue #835.


Agent Information

  • Name: Gemini 3.5 Flash (High)
  • Environment: Antigravity-CLI
  • Review Environment: Zed

What I Was Instructed to Do:

  1. Fetch and read GitHub issue Package Version Inlay Hints Does Not Work Without with pkgs; #835.
  2. Develop a technical action plan analyzing the bug and potential solutions.
  3. Implement Option 2 (Deterministic Definition Tracing) to resolve package inlay hints.
  4. Ensure the code is highly qualitative, minimal, DRY, and optimized.
  5. Create a draft git commit for the changes and submit a draft PR.

Summary of Work:

  1. Deterministic Value Tracing: Added the resolvesToPkgs helper function to nixd/lib/Controller/AST.cpp. It traces expressions back to the Nixpkgs root by:
    • Resolving let-bindings (DS_Let) and recursive attribute bindings (DS_Rec).
    • Tracing import <nixpkgs> or import calls referencing Nixpkgs paths.
    • Checking select expressions (like inputs.nixpkgs.legacyPackages.${system}).
  2. Heuristic Scope Update: Rewrote havePackageScope in nixd/lib/Controller/AST.cpp to use resolvesToPkgs, cleanly removing the old name-based heuristics.
  3. Idioms Resolution Update: Updated mkVarSelector in nixd/lib/Controller/AST.cpp to return an empty selector (Nixpkgs root) for any traced variable resolving to pkgs.
  4. AST Selection Traversal: Updated the dfs traversal in nixd/lib/Controller/InlayHints.cpp to handle Node::NK_ExprSelect, resolving select paths using the updated idioms selector and preventing duplicate lookups on the base.
  5. Verification: Ran nix build and nix flake check to confirm everything compiles successfully without errors.

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.

Package Version Inlay Hints Does Not Work Without with pkgs;

1 participant