The nixd configuration instructions require a nix expression to resolve option systems completions, e.g., as a json:
{
// Tell the language server your desired option set, for completion
// This is lazily evaluated.
"options": { // Map of eval information
// If this is ommited, default search path (<nixpkgs>) will be used.
"nixos": { // This name "nixos" could be arbitary.
// The expression to eval, intepret it as option declarations.
"expr": "(builtins.getFlake \"/home/lyc/flakes\").nixosConfigurations.adrastea.options"
},
// By default there is no home-manager options completion, thus you can add this entry.
"home-manager": {
"expr": "(builtins.getFlake \"/home/lyc/flakes\").homeConfigurations.\"lyc@adrastea\".options"
},
// For flake-parts opitons.
// Firstly read the docs here to enable "debugging", exposing declarations for nixd.
// https://flake.parts/debug
"flake-parts": {
"expr": "(builtins.getFlake \"/path/to/your/flake\").debug.options"
},
// For a `perSystem` flake-parts option:
"flake-parts2": {
"expr": "(builtins.getFlake \"/path/to/your/flake\").currentSystem.options"
}
}
}
Firstly, it’s bizarre to me that I’m meant to put into my nvim config an absolute path to config source which may or may not exist on my machine and I may or may not be currently working on. Is that really how it has to be? I could instead write a nix expression which points to a remote repository instead but this still leads to completions which are potentially decoupled from the source I’m currently looking at. Why aren’t the completions resolved dynamically per project like uh, every other lsp does it?
Secondly, I didn’t write a flake with homeConfigurations as an output, so I can’t use the suggested expression above to expose home-manager options. This way of defining standalone home configs doesn’t seem to be documented in the home-manager manual or really anywhere, but so far as I can tell you’re not meant to define such an output say homeConfigurations.user
and then a nixosConfiguration which depends on e.g. self.homeConfigurations.user
. If you are, I can’t figure out how to do that (see above comment on documentation). Otherwise, I can make a nixosConfiguration with a home-manager module in the usual way by calling home-manager.nixosModules.home-manager
and then I guess just have this dangling additional output homeConfigurations that I have lying around just to make nixd work, which frankly kind of sucks. Is this really how it’s intended to be done?
Another thing I tried was to find a nix expression which depends on home-manager only resolving the options, as nixpkgs#nixos-options does for nixos options, but I couldn’t figure that out either.