Hello,
The NixOS community has been great in helping me with my first steps in this distro. So I’ll ask again few neovim-related issues I couldn’t figure out after 3 days of search.
First, let me tell you that I’m trying to import a working neovim setup from another distro. Then let’s see how I’ve configured neovim. I have this in my home.nix file:
programs.neovim = {
enable = true;
withPython3 = true;
extraPython3Packages = (ps: with ps; [
pynvim
unidecode
black
isort
]);
plugins = with pkgs.vimPlugins; [
{ plugin = *plugin_name*;
type = "lua";
config = builtins.readFile *config_file_path*;
}
...
];
};
(my init.lua file is in the $HOME/.config/nvim folder)
With that most of my plugins work. Most because few are troublesome. Let’s focus on three of them:
-
I have pkgs.vimPlugins.nvim-comment installed but neovim reports that the command
CommentToggle
is not an editor command -
I have pkgs.vimPlugins.nvim-treesitter installed but the command
TSInstall markdown
returns “could not create parser dir '/nix/store/…/nvim-treesitter/parser ': Vim:E739: read-only file system '” -
I have pkgs.vimPlugins.mason-nvim and pkgs.vimPlugins.mason-lspconfig-nvim installed but runngin
checkhealth mason
returns few warnings:
- mason.nvim is not the latest version (I use the unstable channel)
- pip: not available spawn: python3 failed with exit code 1 and signal 0. /run/current-system/sw/bin/python3: No module named pip (note that python3_host_prog and python3_host_prog pip are marked “OK”)
Thanks again for your assistance.
Thanks for the feedback. I’m used to packer but it’s not maintained anymore so may be a good time to switch to lazy.
I’ll see if I can have it work in NixOS.
It worked. Thanks! Just a question though: why is there instructions and all the packages in NixOS if it’s not yet reliable?
As other comments point out, they are usually not properly packaged through nix.
If you read the vim/plugins
modules, for most plugins, the derivation just downloads the plugin, puts it to nix-store
, and makes it available to the editor through environment variables. So it’s similar to the binary distributed software. Two most notable restrictions:
- Nix is not aware of transient dependencies.
- The plugin is not aware of the
nix-store
model.
So for plugins that don’t have external dependencies (or dependencies other than the “common” ones like python or sh that happen to be available), and that don’t interact with the filesystems, this approach would be fine, but the more complex ones would fail.
In your example, mason
failed because of 1, home-manager wasn’t aware that the pip
module is a transient dependency of this plugin; and treesitter
failed because of 2, because it doesn’t know that nix-store
is read-only and should be managed by nix
.
There are no general solutions, but people may have nixified some plugins on a case-by-case basis. If you don’t want to spend a lot of time (and remember that it might be broken by the next plugin upgrade), as others have suggested, take the traditional plugin management approach. (Personally, I use LunarVim which uses Lazy.nvim
and it’s been working fine.)