Hello,
What is the best way to specify runtime dependencies for Neovim plugins in a custom Neovim package?
For example, conform-nvim
requires the formatter application, let’s say stylua
, to be available at runtime. I’ve only been able to make it work by overridding the package attributes. Is there a better way?
{
description = "Neovim devenv";
inputs = {nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";};
outputs = {
self,
nixpkgs,
}: let
system = "x86_64-linux";
pkgs = import nixpkgs {inherit system;};
myneovim = pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped {
autowrapRuntimeDeps = true;
plugins = with pkgs.vimPlugins; [conform-nvim];
luaRcContent = ''
require("conform").setup({
formatters_by_ft = {
lua = { 'stylua' },
},
})
'';
};
neovim = myneovim.overrideAttrs (oldAttrs: {
runtimeDeps = oldAttrs.runtimeDeps ++ [pkgs.stylua];
});
in {
packages.${system}.default = neovim;
};
}
> nix eval .#default.runtimeDeps
[
«derivation /nix/store/7m3v6mmk6hmvb0ybyl9kw9v4sp61xnii-neovim-ruby-env.drv»
«derivation /nix/store/h7dxibb64bn8inwijxw6ljs4s218cpp5-stylua-2.1.0.drv»
]