Recently I wrote a brand new nix language server, which links with official NixOS/nix library.
Nixd is a Nix language server that directly uses (i.e., is linked with) the official Nix library (GitHub - NixOS/nix: Nix, the purely functional package manager).
Some notable features provided by linking with the Nix library include:
- Nixpkgs option support, for all option system (NixOS/home-manager/flake-parts).
- Diagnostics and evaluation that produce identical results as the real Nix command.
- Shared eval caches (flake, file) with your system’s Nix.
- Native support for cross-file analysis.
- Precise Nix language support. We do not maintain “yet another parser & evaluator”.
- Support for built-ins, including Nix plugins.
We provide native options auto-completion system, by lazily evaluated merged option set. (Goto declarations also work)
Note that not only home-manager options, generally all nixpkgs option system are supported. We have tested nixos options, home-manager options, and even flake-parts.
And, we know the lambda arguments passed to your nix file, e.g. by
Also, we complete variables inside
with expressions (and also complete
lib, with hover support). Note that the diagnostic missing “name” is reported.
We support all kinds of evaluation & cross-file analysis by allow our user explicitly specify a nix installable. Which will be used for cross-file analysis pivot. For more information, please see:
So how do these things work? I’ve written a brief explanation here. TLDR: we use callbacks and inject custom AST nodes to nix evaluator.
- Currently critical features like “rename” & “semantic tokens” are not yet supported yet. Because we cannot retrieve range information from nix ASTs. Many language features like AST-based editing do expect ASTs preserving enough information.
- Source Tree Abstraction. We do need provide a VFS to nix evaluator, and provide file contents from the memory. Because buffers you are editing does nothing to do with real filesystems, however, we need to tell nix do not access filesystems directly. This prevents us collecting language information from pure-evaluated nix flakes.
I just released the first version (which means all trivial features are implemented and tested). And the code base is in rapid development. The status page could be found here. I just submitted a PR: nixpkgs#236675
Any questions & feature request please comment here
Main topic: Nixd 1.1.0 released
You don’t need to manually set “eval depth”. Nixd will evaluate where you touched lazily.
Show nix stack trace (completely consistent with official implementation)
The nixpkgs option auto-completion subsystem will show you example if specified.