From 20a7c9230644597fd1c37a23c878804e27c39736 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 7 Oct 2025 18:16:35 +0100 Subject: [PATCH] modules/lsp: handle missing package in server option desc The `lsp.servers.` option description links to the server's homepage if it can evaluate the default package's `meta.homepage`. However, users may evaluate this description, e.g. when building NixOS docs with `documentation.nixos.includeAllModules`. Further, users may have a different nixpkgs revisions to ours. Therefore, we need to allow for the package not being in nixpkgs. Since `mkPackageOption` will throw in the default, we can catch it with `tryEval`. --- modules/lsp/servers/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/lsp/servers/default.nix b/modules/lsp/servers/default.nix index 3ea31130..8223b421 100644 --- a/modules/lsp/servers/default.nix +++ b/modules/lsp/servers/default.nix @@ -31,8 +31,13 @@ let (opt: opt.type.getSubOptions opt.loc) # Get suboptions of `lsp.servers.` (opts: opts.${name}.type.getSubOptions opts.${name}.loc) - # Get package option's homepage - (opts: opts.package.default.meta.homepage or null) + # Get the default package + (opts: opts.package.default or null) + # The default throws if mkPackageOption can't find the package + # E.g. mismatched nixpkgs revision + (package: (builtins.tryEval package).value) + # Get package's homepage + (package: package.meta.homepage or null) ]; # If there's a known homepage for this language server,