KFearsoff / NixOS-config

20 stars 0 forks source link

Interesting approach #57

Open 99linesofcode opened 2 months ago

99linesofcode commented 2 months ago

I think this is a pretty elegant approach and it seems to allow me to stay as close to the LazyVim defaults as possible. I read your blog post but I'm still a bit unclear on the purpose of this section in your init config. Could you explain it in more detail? Thanks for sharing!

https://github.com/KFearsoff/NixOS-config/blob/6b42e069cc917112f99447a87650da9cccdc12ed/nixosModules/neovim/default.nix#L201

KFearsoff commented 1 month ago

Hi!

I might be completely off the mark here, but I thought I saw you quite recently somewhere in NixOS spaces, asking about installing LazyVim and being unhappy with people telling you to move to some Nix-native solution like NixVim? If so, I'm glad to be of help!

Sure, let me try to explain this bit to the best of my ability. It's been a while since I used Neovim, to be honest. So Neovim has a packpath, which is something like a general Linux PATH, but for Neovim plugins and packages. Nix uses a wrapper around Neovim, which resets the packpath to some paths to /nix/store. I think this line does a few things:

  1. Runs pkgs.vimUtils.packDir function with our finalPackage.passthru.packpathDirs, which produces a new /nix/store path that leads to the actual packpath
  2. Appends /pack/myNeovimPackages/start to it. I don't quite remember why we need it, but just step 1 is not enough, and the new path that is created here is actually expected by Neovim
  3. Sets the lazy.nvim's dev path to this /nix/store path, which makes lazy.nvim look into this directory for when a package is marked with dev

By the way, you can actually specify the allowed dev paths as a wildcard, using patterns = {""}. This came up in https://github.com/folke/lazy.nvim/pull/1676#issuecomment-2248942233 , and I still haven't updated the blog post. My bad!