nixd icon indicating copy to clipboard operation
nixd copied to clipboard

Implement URI resolution for Nix Flake input URIs

Open PAI5REECHO opened this issue 2 years ago • 1 comments

nil implements a limited version of link resolution for Nix Flake input URIs. It turns Flake input URIs into clickable links (i.e. github:nix-community/nixd opens https://github.com/nix-community/nixd in default web browser): https://github.com/oxalica/nil/blob/73eeaa64d847f9db42e6d4f7bc80ca04011933a5/crates/ide/src/ide/links.rs#L74

It'd be nice to see a more complete version of this LSP functionality implemented in nixd, one that actually resolves (also recursively resolves) Flake input links fully and considers nix registry list for user defined registry URLs.

Some test case examples:

  • github:nix-community/nixd -> https://github.com/nix-community/nixd
  • github:nix-community/nixd/29904e121cc775e7caaf4fffa6bc7da09376a43b -> https://github.com/nix-community/nixd/commit/29904e121cc775e7caaf4fffa6bc7da09376a43b
  • github:nix-community/nixd?ref=pull/252/head -> https://github.com/nix-community/nixd/pull/252
  • blender-bin -> https://github.com/edolstra/nix-warez/tree/master/blender
  • gitlab:openldap/openldap?host=git.openldap.org -> https://git.openldap.org/openldap/openldap

PAI5REECHO avatar Oct 17 '23 21:10 PAI5REECHO

Actually there do have some "patterns" in nix files, which is the type system in nil, but in nixd for now all files are treated equally.

For example, we currently do not have any type system or assumption that flake.nix is actually a flake root, this should be carefully introduced to maintain consistency between nixd and official one.

It'd be nice to see a more complete version of this LSP functionality implemented in nixd, one that actually resolves (also recursively resolves) Flake input links fully and considers nix registry list for user defined registry URLs.

I agree that this would be nice. Maybe a queued feature after new languages frontend merged?

fully and considers nix registry list for user defined registry URLs.

To do this I think the best solution is just sharing the same code with official nix, however there might be some refactor in upstream (e.g. introducing libnixflake) for now.

inclyc avatar Oct 18 '23 16:10 inclyc