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:

  1. I have pkgs.vimPlugins.nvim-comment installed but neovim reports that the command CommentToggle is not an editor command

  2. 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 '”

  3. 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.

5 points
*

Not sure about 1, but 2 and 3 both have the same answer. Both TSInstall and Mason are just trying to install other software packages on your system, and you’re on NixOS, so of course they can’t do that. You don’t install your software, you declare it. Add the Treesitter parsers you need right next to your plugins (there is a sub collection under the vimPlugins collection just for Treesitter parsers), and put whatever Mason would be installing into your user packages instead.

That said, I agree with the other commenter. Even though the community has done a lot of work on rich config options for Neovim, they’re just too far away from the normal way of doing things in the Neovim world, and plenty of plugins are written in ways that assume it’s configured in “normal” ways. Plus configuring Neovim is already kinda like assembling your own car from parts in any case, so it’s honestly better to just use nix to install Lazyvim or whatever flavor of choice and let it handle the plugin management/config. And believe me, I really tried to do it all in Nix, I wanted to do it that way. But it’s just not worth the headache at this point

permalink
report
reply
2 points
*

Thanks for this feedback, it helps me feel a little bit less stupid :) With everything setup in NixOS documentation for neovim in appearance I thought really dumb to not be able to have it worked.

Using the approach proposed by @flashgnash (i.e. using lazy.vim) let me install neovim and all my plugins.

permalink
report
parent
reply
1 point

It’s also a nightmare if you want your config to work with both nix and non nix platforms. If I’m using my config on windows or at work, I’m not going to have nix and home manager to interpret the nix version of my vim config. On my systems with home manager, I’d like be able to install my nvim config as part of home manager rebuild. If I have home manager pull my configs git repo, it causes lazy to freak out whenever I try to update my plugins. It’d be nice to have some sort of integration with lazy that exists with cargo and similar tools but it doesn’t look like anyone’s been working on it.

permalink
report
parent
reply
5 points

Take a look at NixVim. I had to convert my entire config to Nix, but in the end it’s now 100% reproduceable

permalink
report
reply
4 points

Have tried this myself and never had much luck trying to install nvim plugins via nix.

I’ve found the best way is to just use the plugin managers built for neovim, I’m not sure if this applies to all of them but lazy.nvim seems to be fairly declarative anyway, have home-manager map a directory to .config/nvim/ and away you go

As a side note though I think it is rather silly just how many different neovim package managers there are, which at the end of the day all do the same thing in very similar ways

permalink
report
reply
1 point

I followed this guide from VimJoyer and it works like a charm. Have been using this approach for quite a while now. It just uses raw nix with homemanager

permalink
report
parent
reply
1 point

Here is an alternative Piped link(s):

this

Piped is a privacy-respecting open-source alternative frontend to YouTube.

I’m open-source; check me out at GitHub.

permalink
report
parent
reply
1 point
*

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.

permalink
report
parent
reply
1 point

It worked. Thanks! Just a question though: why is there instructions and all the packages in NixOS if it’s not yet reliable?

permalink
report
parent
reply
2 points

I have no idea, from what I gather there aren’t all the packages

I’m not sure what if anything installing them via nix does I’ve just come to the realisation it’s already declarative so why would people bother getting it working under nix

permalink
report
parent
reply
1 point

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:

  1. Nix is not aware of transient dependencies.
  2. 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.)

permalink
report
parent
reply
1 point
1 point

Thank you for your help. I ended up using the approach proposed by @flashgnash (i.e. using lazy.vim) which let me install neovim and all my plugins.

permalink
report
parent
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 7.7K

    Monthly active users

  • 6.5K

    Posts

  • 179K

    Comments