I know how to override a Vim plugin but I’m having trouble in understanding how I can override a Vim plugin that depends on NodeJs, as it is the case with any coc.nvim plugin.
I want to override coc-metals
, specifically, which is defined under vim-plugins/generated.nix.
The override compiles fine (using Home Manager) but it still brings in the old version defined in nodePackages if I don’t override this one too.
I tried defining an overlay in this way:
self: super:
{
nodePackages = super.nodePackages.coc-metals.override {
coc-metals = (super.callPackage ./programs/neovim/node-pkgs.nix {}).coc-metals;
};
}
Where node-pkgs.nix
is defined as follows (truncating dependencies to make it short):
{ nodeEnv, globalBuildInputs ? [], ... }:
{
coc-metals = nodeEnv.buildNodePackage {
name = "coc-metals";
packageName = "coc-metals";
version = "0.9.0";
src = fetchurl {
url = "https://registry.npmjs.org/coc-metals/-/coc-metals-0.9.0.tgz";
sha512 = "DfDQbgbnau8CvTa1uEkYuZnMSaOqnQDvNxbwRi24q3t8z/DwMwEubon/lITGM02CkQH5PnfhE5fJYxt6/Q1wvA==";
};
dependencies = [ ... ];
buildInputs = globalBuildInputs;
meta = {
description = "coc.nvim extension for Metals, the Scala language server";
license = "Apache-2.0";
};
production = true;
bypassCache = true;
reconstructLock = true;
};
}
And another override of the vim plugin:
{ pkgs, nodePackages, ... }:
{
coc-metals = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "coc-metals";
version = nodePackages.coc-metals.version;
src = "${nodePackages.coc-metals}/lib/node_modules/coc-metals";
};
}
Finally, I define the overlay in home.nix
to be available by the time Home Manager runs:
nixpkgs.overlays = [
(import ./node-overlay.nix)
];
There are a lot of moving parts involved and I am not sure if this is the right way to do it. I tried many things and I always get different errors. If anyone familiar with this can shed any light, that would be highly appreciated