From 654788560e2745bcc8103037446dcbba31944205 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Thu, 12 Sep 2024 11:13:32 +0100 Subject: [PATCH] nixvimInfo: access `package.default` using `tryEval` Allow getting `meta.homepage` from the default package to fail gracefully when the nixpkgs channel lock is out-of-sync with ours. --- lib/neovim-plugin.nix | 8 +++++--- lib/vim-plugin.nix | 6 ++++-- plugins/lsp/language-servers/_mk-lsp.nix | 5 ++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/neovim-plugin.nix b/lib/neovim-plugin.nix index fce2c0a7fe..a01f3b9dca 100644 --- a/lib/neovim-plugin.nix +++ b/lib/neovim-plugin.nix @@ -49,6 +49,7 @@ }@args: let namespace = if isColorscheme then "colorschemes" else "plugins"; + extraConfigNamespace = if isColorscheme then "extraConfigLuaPre" else "extraConfigLua"; module = { @@ -60,14 +61,15 @@ let cfg = config.${namespace}.${name}; opt = options.${namespace}.${name}; - extraConfigNamespace = if isColorscheme then "extraConfigLuaPre" else "extraConfigLua"; + # `package.default` will throw "not found in pkgs" if the nixpkgs channel is mismatched + pkg = (builtins.tryEval opt.package.default).value; + url = args.url or pkg.meta.homepage or null; in { meta = { inherit maintainers; nixvimInfo = { - inherit description; - url = args.url or opt.package.default.meta.homepage; + inherit url description; path = [ namespace name diff --git a/lib/vim-plugin.nix b/lib/vim-plugin.nix index c7c9406d69..f7f3dc40c7 100644 --- a/lib/vim-plugin.nix +++ b/lib/vim-plugin.nix @@ -61,13 +61,15 @@ let cfg = config.${namespace}.${name}; opt = options.${namespace}.${name}; + # `package.default` will throw "not found in pkgs" if the nixpkgs channel is mismatched + pkg = (builtins.tryEval opt.package.default).value; + url = args.url or pkg.meta.homepage or null; in { meta = { inherit maintainers; nixvimInfo = { - inherit description; - url = args.url or opt.package.default.meta.homepage; + inherit url description; path = [ namespace name diff --git a/plugins/lsp/language-servers/_mk-lsp.nix b/plugins/lsp/language-servers/_mk-lsp.nix index 8d1df8a8fd..ad9bcaf803 100644 --- a/plugins/lsp/language-servers/_mk-lsp.nix +++ b/plugins/lsp/language-servers/_mk-lsp.nix @@ -30,11 +30,14 @@ with lib; let cfg = config.plugins.lsp.servers.${name}; opt = options.plugins.lsp.servers.${name}; + # `package.default` will throw "not found in pkgs" if the nixpkgs channel is mismatched + pkg = (builtins.tryEval opt.package.default).value; + url = args.url or pkg.meta.homepage or null; in { meta.nixvimInfo = { # TODO: description - url = args.url or opt.package.default.meta.homepage or null; + inherit url; path = [ "plugins" "lsp"