oxalica / nil

NIx Language server, an incremental analysis assistant for writing in Nix.
Apache License 2.0
1.32k stars 40 forks source link

Feature request: provide links for `flake:` references #146

Open ian-h-chamberlain opened 1 month ago

ian-h-chamberlain commented 1 month ago

Providing links for flake references like url = "github:zhaofengli/nix-homebrew"; is really convenient — would it be possible to resolve registry flakes as well? For example, I have some pinned entries that would be nice to link to:

  inputs = {
    nixpkgs.url = "flake:nixpkgs/nixos-24.05";
    nixos-unstable.url = "flake:nixpkgs/nixos-unstable";

    nixpkgs-darwin.url = "flake:nixpkgs/nixpkgs-24.05-darwin";
    nixpkgs-unstable.url = "flake:nixpkgs/nixpkgs-unstable";

    nix-homebrew = {
      url = "github:zhaofengli/nix-homebrew"; # <-- This one becomes a link, awesome!
      inputs.nixpkgs.follows = "nixpkgs-darwin";
      inputs.nix-darwin.follows = "nix-darwin";
    };
  }

These ultimately resolve to github: flake refs:

$ nix registry list  | grep -E 'nixpkgs|darwin'
user   flake:nixpkgs github:NixOS/nixpkgs/c3392ad349a5227f4a3464dce87bcc5046692fce
global flake:nix-darwin github:LnL7/nix-darwin
global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable

I am guessing that some metadata about these are already evaluated at some point, since go-to-definition works on their store paths, so maybe it's just a matter of plumbing through a bit of extra metadata somewhere? Thanks!