How to make nvim plugins lazyload in hm?

I am struggling with nvim plugins.

Here is my nix code:

with import <nixpkgs> { };
{
  xdg.configFile."nvim/lua/plugins" = {
    recursive = true;
    source = ./src/nvim;
  };
  programs = {
    neovim = {
      enable = true;
      extraPackages = with pkgs; [
      ];
      plugins = with pkgs.vimPlugins; [
        lazy-nvim
      ];
      extraLuaConfig = with pkgs.vimPlugins; ''
        vim.g.mapleader = " "
        require("lazy").setup({
          performance={
            reset_packpath=false,
            ret={
              reset=false,
            }
          },
          dev={
            path="${pkgs.vimUtils.packDir config.programs.neovim.finalPackage.passthru.packpathDirs}/pack/myNeovimPackages/start",
            patterns={
              ""
            },
          },
          install={
            missing=false,
          },
          spec={
            { import = "plugins" },
          },
        })
      '';
    };
  };
}

And I just import it in my home.nix. When I type home-manager switch, it read:

       error: attribute 'programs' missing
       at /home/luke/.config/home-manager/nvim.nix:77:43:
           76|           dev={
           77|             path="${pkgs.vimUtils.packDir config.programs.neovim.finalPackage.passthru.packpathDirs}/pack/myNeovimPackages/start",
             |                                           ^
           78|             patterns={

How to write the ${pkgs.vimUtils.packDir xxx}to make lazy.nvim set the true packpathDirs?

Thanks for who can solve my problem. It’s a hard question for me.

You should change the first line to { config, pkgs, … }:. Then it would be a proper home-manager module.

1 Like

Oh, I mean, the home-manager module like some magic for me. Thanks for ask me about the solution.