Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Setup LazyVim using Nix and home-manager#1972

azuwis started this conversation inRecipes
Nov 8, 2023· 30 comments· 87 replies
Discussion options

Here is how to setup LazyVim using Nix and home-manager.

This can reuse files from pkgs.vimPlugins.*, works without internet after nix build.

{config,lib,pkgs, ...}:{programs.neovim={extraPackages=withpkgs;[# LazyVimlua-language-serverstylua# Telescoperipgrep];plugins=withpkgs.vimPlugins;[lazy-nvim];extraLuaConfig=letplugins=withpkgs.vimPlugins;[# LazyVimLazyVimbufferline-nvimcmp-buffercmp-nvim-lspcmp-pathcmp_luasnipconform-nvimdashboard-nvimdressing-nvimflash-nvimfriendly-snippetsgitsigns-nvimindent-blankline-nvimlualine-nvimneo-tree-nvimneoconf-nvimneodev-nvimnoice-nvimnui-nvimnvim-cmpnvim-lintnvim-lspconfignvim-notifynvim-spectrenvim-treesitternvim-treesitter-contextnvim-treesitter-textobjectsnvim-ts-autotagnvim-ts-context-commentstringnvim-web-deviconspersistence-nvimplenary-nvimtelescope-fzf-native-nvimtelescope-nvimtodo-comments-nvimtokyonight-nvimtrouble-nvimvim-illuminatevim-startuptimewhich-key-nvim{name="LuaSnip";path=luasnip;}{name="catppuccin";path=catppuccin-nvim;}{name="mini.ai";path=mini-nvim;}{name="mini.bufremove";path=mini-nvim;}{name="mini.comment";path=mini-nvim;}{name="mini.indentscope";path=mini-nvim;}{name="mini.pairs";path=mini-nvim;}{name="mini.surround";path=mini-nvim;}];mkEntryFromDrv=drv:iflib.isDerivationdrvthen{name="${lib.getNamedrv}";path=drv;}elsedrv;lazyPath=pkgs.linkFarm"lazy-plugins"(builtins.mapmkEntryFromDrvplugins);in''        require("lazy").setup({          defaults = {            lazy = true,          },          dev = {            -- reuse files from pkgs.vimPlugins.*            path = "${lazyPath}",            patterns = { "" },            -- fallback to download            fallback = true,          },          spec = {            { "LazyVim/LazyVim", import = "lazyvim.plugins" },            -- The following configs are needed for fixing lazyvim on nix            -- force enable telescope-fzf-native.nvim            { "nvim-telescope/telescope-fzf-native.nvim", enabled = true },            -- disable mason.nvim, use programs.neovim.extraPackages            { "williamboman/mason-lspconfig.nvim", enabled = false },            { "williamboman/mason.nvim", enabled = false },            -- import/override with your plugins            { import = "plugins" },            -- treesitter handled by xdg.configFile."nvim/parser", put this line at the end of spec to clear ensure_installed            { "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },          },        })      '';};# https://github.com/nvim-treesitter/nvim-treesitter#i-get-query-error-invalid-node-type-at-positionxdg.configFile."nvim/parser".source=letparsers=pkgs.symlinkJoin{name="treesitter-parsers";paths=(pkgs.vimPlugins.nvim-treesitter.withPlugins(plugins:withplugins;[clua])).dependencies;};in"${parsers}/parser";# Normal LazyVim config here, see https://github.com/LazyVim/starter/tree/main/luaxdg.configFile."nvim/lua".source=./lua;}
You must be logged in to vote

Replies: 30 comments 87 replies

Comment options

Where do I put my own LazyVim config? For examplehttps://github.com/multivac61/.config/blob/main/nvim/lua/config/lazy.lua

You must be logged in to vote
10 replies
@multivac61
Comment options

How do you install mason? Or do you use something instead?

@azuwis
Comment options

Read the comments of spec. For more references, seehttps://github.com/azuwis/nix-config/tree/master/common/lazyvim

@multivac61
Comment options

So you don't use mason at all. Do you use anything else to maintain and install lsps?

@azuwis
Comment options

Use

    programs.neovim.extraPackages = with pkgs; [      lua-language-server      ansible-language-server      terraform-ls    ];
@multivac61
Comment options

Thank you for your kind replies. Greatly appreciated.

Comment options

I'm getting the following error withthis config.

error:       … while calling the 'derivationStrict' builtin         at /builtin/derivation.nix:9:12: (source not available)       … while evaluating derivation 'home-manager-generation'         whose name attribute is located at /nix/store/vl7r7pssaqdihzm6zbnj3klh8dysfdfd-nixos/nixos/pkgs/stdenv/generic/make-derivation.nix:348:7       … while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'         at /nix/store/vl7r7pssaqdihzm6zbnj3klh8dysfdfd-nixos/nixos/pkgs/build-support/trivial-builders/default.nix:87:14:           86|       enableParallelBuilding = true;           87|       inherit buildCommand name;             |              ^           88|       passAsFile = [ "buildCommand" ]       (stack trace truncated; use '--show-trace' to show the full trace)       error: getting status of '/home/dylan/.config/home-manager/lua': No such file or directory
You must be logged in to vote
3 replies
@dltompki
Comment options

I added a lua dir (empty) and I'm no longer getting an error but I still don't have an init.lua

[09:02:54] dylan@maple-nix /home/dylan/.config/nvim  > tree . -l.├── lua -> /nix/store/qm0gc3ac6f1rz3dnwawl4i4v1na3rxmp-home-manager-files/.config/nvim/lua└── parser -> /nix/store/qm0gc3ac6f1rz3dnwawl4i4v1na3rxmp-home-manager-files/.config/nvim/parser    ├── c.so -> /nix/store/1g417k76s5j7cw6lkqwlrsz2j9adba63-c-grammar-0.0.0+rev=212a80f/parser    └── lua.so -> /nix/store/s0ksvj9s75ih71x6qwlbphzmgqlir0lr-lua-grammar-0.0.0+rev=9668709/parser3 directories, 2 files
@azuwis
Comment options

Missingprograms.neovim.enable = true

@dltompki
Comment options

Thanks for the quick reply.

I decided to usenixvim instead.

Comment options

Is it possible to use this without home-manager so it can be run with the nix run command?

You must be logged in to vote
5 replies
@azuwis
Comment options

A demo to setup LazyVim using NixVimhttps://github.com/azuwis/lazyvim-nixvim/tree/master

nix run github:azuwis/lazyvim-nixvim
@jla2000
Comment options

@azuwis Any idea how to also include treesitter parsers in the nixvim flake?

@azuwis
Comment options

https://nix-community.github.io/nixvim/plugins/treesitter/index.html should work.

@jla2000
Comment options

It did not, since rtp gets cleared when lazy.nvim starts :)
I got it working now though with some fixes

@marcokuoni
Comment options

A demo to setup LazyVim using NixVimhttps://github.com/azuwis/lazyvim-nixvim/tree/master

nix run github:azuwis/lazyvim-nixvim

I really like this. But what i don't get. How can i use the LazyExtras. First of all how does it working through the IDE, cause i can't find the settings it does? -> ok this is comming by default with LazyVim found under lazyPath from nix config. So i think the json just activates it then. So then i just need to find out how to overwrite the lua configs with nix and how to manage lazyvim.json with nix

And second, how can i insert the lazyvim.json in nix (the file which saves the enabled extras)?

Comment options

I'm just stepping into (and loving) Nix/nix-darwin/Home Manager world and have been keeping this discussion in mind. This morning I adopted this config (module? function? 🤷‍♂️) and it's working great. Thanks@azuwis for sharing this and your broader Nix configuration, super helpful!

You must be logged in to vote
0 replies
Comment options

Thanks, this config works great! My only issue is that when I startup neovim, I get this error message: "No specs found for module plugins". How can I fix this?

You must be logged in to vote
6 replies
@sylvesterroos
Comment options

Same issue here, not (yet) gone for me. Replying to keep the discussion active

@azuwis
Comment options

Remove those lines if you don't setup any LazyVim plugins:

            -- import/override with your plugins            { import = "plugins" },
@sylvesterroos
Comment options

Yup, that removed the error! Could you explain to me what that does? I don't have much understanding of the Nix language, so I simply copy-pasted your code 😅

@sylvesterroos
Comment options

This seems to have fixed itself, not sure how but I'm not going to complain.

I think I see what happened. Removing{ import = "plugins" } indeed makes the error go away, but it also goes away when specify a LazyVim plugin you want to use (inlua/plugins/some-plugin.lua).

@shivajreddy
Comment options

i am trying to override some of the configuration that lazyvim has setup, and I am so very confused on to do this, given the fact that lazyvim is being setup by nixvim through theextraConfigLua property.
So when you 'lua/plugins/some-plugin.lua' is this lua directory in .config ? So does that mean, to write this config 'nix way' i make a .lua file in my nix directory and then tell nix to copy this .lua into .config directory?

Here is my configuration, (i am trying to implement the@azuwis way of things but in my home-manager)https://github.com/shivajreddy/dotfiles/blob/main/home/apps/nixvim/default.nix

Comment options

What is the purpose of the plugin list in theextraLuaConfig block? Why would you use plugins from nixpkgs if lazy.nvim can download them as well?

You must be logged in to vote
1 reply
@azuwis
Comment options

Using vimPlugins from nixpkgs make the setup reproducible, and works in air-gapped environment.

In Nix, the build binary cache can be shared usingnix-store --serve,Cachix or similar, make the setup much faster it you manage hundreds of machines.

You can make the plugin an empty list[], then lazy.nvim will download all plugins.

Comment options

Hey there, sorry for the newb comment/ question, but I am new to both nix, and nvim. I have been trying to add obsidian-nvim to this setup. I think I have gotten 75% of the way there, but I keep getting this error ``` - ERROR Issues were reported when loading your specs:

  • ERROR No specs found for module obsidian.lua```

and, obsidian is showing as installed, but not loaded when running lazy. I have also manually set the plugin in xdg.config file, and no change.. any advice is appreiciated. TIA

You must be logged in to vote
1 reply
@johnallen3d
Comment options

Maybe share a little configuration? It's not clear from context whatobsidian.lua is referring to. Do you haveobsidian-nvim in my list of Nix packages? eg.

...extraLuaConfig=letplugins=withpkgs.vimPlugins;[# LazyVimLazyVim...obsidian-nvim...
Comment options

For anyone interested, I have created a standalone flake based on this (without nixvim ;) ), with additional fixes for treesitter and all the configuration done in regular lua :)
https://github.com/jla2000/lazyvim-nix

You must be logged in to vote
3 replies
@qlibp
Comment options

how could I copy all the downloaded stuffs to another offline machine so that I could bundle the dev env in ci and copy them on those offine machines

@shivajreddy
Comment options

@qlibp you look at my dotfiles and the nvim config, i added comments there on how to get lazyvim to get to work with nixos.

@qlibp
Comment options

can I use it on non-nixos machine?

Comment options

This no longer seems to be working for me after updating today (using unstable). Treesitter seems to point to its own dir now.

Could not create parser dir ' /nix/store/1j21cnwa445dnrh9kdqvxhl5rwcljy07-lazy-plugins/nvim-treesitter/parser ':  Vim:E739: Cannot create directory /nix/store/1j21cnwa445dnrh9kdqvxhl5rwcljy07-lazy-plugins/nvim-treesitter/parser: read-only file system

When trying to set parser_install_dir...

Could not create parser dir ' /home/user/.config/nvim/parser/parser ':  Vim:E739: Cannot create directory /home/jonathan/.config/user/parser/parser: read-only file system

And when setting it to my neovim config dir specifically, it states that parser needs to be read/write (which it obviously isn't in this case).

You must be logged in to vote
2 replies
@clamydo
Comment options

Same for me, related#3702

@clamydo
Comment options

require("lazy").setup({...spec= {          {"LazyVim/LazyVim",import="lazyvim.plugins"},...          {"nvim-treesitter/nvim-treesitter",opts=function(_,opts)opts.ensure_installed= {}end,          },        },      })

This seems to do the trick.

Comment options

Thanks for setting this up.

I did get it to work, but for some reason it is installing both cattpuccin and tokyonight even after I removed both from the nix config and the lazy.lua file. It is also defaulting to tokyonight, and not the colorscheme I've istalled and asked to use.

The same setup works with my own standlone lazyvim install.. so I'm kind of lost to what what is happening here.

Any thoughts?

You must be logged in to vote
2 replies
@azuwis
Comment options

Try add this to your lazyvim spec:

  {    "catppuccin/nvim",    name = "catppuccin",    enabled = false,  },  {    "folke/tokyonight.nvim",    enabled = false,  },  {    "LazyVim/LazyVim",    opts = {      colorscheme = "<theme_name>",    },  }
@pfassina
Comment options

Thanks.
Apparently the name used to import by lazy was different from the name on vimPlugins, and that preventing neovim fom actually finding the plugin.

I had it asno-clown-fiesta-nvim on my nix file, but had to useno-clown-fiesta on my lua file.
Apparently it was defaulting to TokyoNight after not finding the plugin.

I don't know what the cattpuccin was all about..

Comment options

One thing that I noticed is that I'm not getting any lsp autocomplete suggestion on cmp.
The LSP seems to be working (at least for lua) since I'm seeing diagnostics and I can jump to definitions, but no auto complete.

Anything that I should add to my lua config to get it to work?

You must be logged in to vote
1 reply
@pfassina
Comment options

Ok, tried a few different approaches, and got it workng by simply adding the following code to alsp.nvim file.

return {  {    "neovim/nvim-lspconfig",    opts = {      servers = {        nil_ls = {},        nixd = {},      },    },  },}
Comment options

I made a more up-to-date Home Manager module for LazyVim. All you need to do is enable it:programs.lazyvim.enable = true;.
Check it out and please let me know what you think!
https://github.com/matadaniel/LazyVim-module

You must be logged in to vote
5 replies
@cameronraysmith
Comment options

Nice work on this@matadaniel!

Something along these lines seems like the most sustainable approach. Some would likely argue it should be refactored to integrate with nixvim and eventually be able to take advantage of the work there on providing modules for other plugins not included in LazyVim+extras.

@matadaniel
Comment options

Thank you!

I have not had a good look at everything that nixvim has to offer as most of what I need is provided by LazyVim. The few plugins I configure myself were brought in from my old setup without nix. The module lets me use the same configuration and has lazy.nvim take care of everything, just as it always has.

@cameronraysmith
Comment options

Yea possibly there's no need. I'm not sure if you get a bit of type safety for free by reusing the nixvim modules a bit more likenvix since you're already manually including binding for each of the lazyvim extras (e.g.here and the other leaves of thelazyvim/extra tree). I don't know enough about how lazyvim itself functions to be sure if there's a significant difference to replicating each of its plugins/extras in nix modules or pushing everything down to the direct management of LazyVim/lazy.nvim. It's possible what you've done here is the best way to avoid a situation where you'd have to essentially copy and paste lots of lua from the LazyVim repo itself into a system designed to mirror it from nix. The latter is obviously not desirable!

In any case, this is probably worthy of separate discussion in LazyVim-module's issues. Many thanks again for putting this together!

@cameronraysmith
Comment options

@azuwis your solution is certainly a great way to get started here so many thanks for posting this nice solution and creating the discussion. I'd be curious to know if you agree@matadaniel's home-manager module provides a sane way to maintain a feature-complete and extensible mirror of lazyvim that's accessible from nix. It would be nice to eventually coalesce around a single repo that could become a candidate to include in nix-community or similar.

@matadaniel
Comment options

I created a place to discuss LazyVim on Nix:matadaniel/LazyVim-module#5. Please share your thoughts!

Comment options

Wanted to share my setup for lazyvim in my nixos+hm flake.
I like to be flexible and don't want to manage config or plugins with nix. I just have my LazyVim repository as a flake input:

inputs.lazyvim={url="github:PaideiaDilemma/LazyVim";flake=false;};

and link the configuration into XDG_CONFIG_HOME like this:

{config,inputs,lib,pkgs,  ...}:{# These could also go into programs.neovim.extraPackages.# When i am developing and notice I am missing something I usually just launch myself into a nix shell or i add it here.home.packages=withpkgs;[clang-toolsfdgccgitgolazygitnodejsripgrepunzipjdk17zig];xdg.configFile."lazyvim/init.lua"={source="${inputs.lazyvim}/init.lua";};xdg.configFile."lazyvim/lua"={source="${inputs.lazyvim}/lua";};programs.neovim={enable=true;vimAlias=true;vimdiffAlias=true;defaultEditor=true;};};}

Then I have my repo cloned and a symlink.config/testvim that points to it, allowing me to useNVIM_APPNAME=testvim vim to test out config changes. When i am done i just update withnix flake update lazyvim.

Has been working well for me.

You must be logged in to vote
1 reply
@PaideiaDilemma
Comment options

Two things I forgot to mention:

  1. I haveNVIM_APPNAME=lazyvim in my environment. I you don't, link the files to.config/nvim instead of.config/lazyvim to make it work.
  2. If you would want to lock your plugin versions, you can also link the lock-file.
xdg.configFile."lazyvim/lazyvim.json"={source="${inputs.lazyvim}/lazyvim.json";};

But then you cannot update via lazy.nvim, since it will obviously be read only.
I don't care though and if i really need to because smth broke, I just manually copy the lock-file from my main system to another machine.

Comment options

Hey, I am having some issues with setting up and installing new plugins

for example if I wanted to installharpoon2, I thought that doing this would be enough

Add the plugin

      extraLuaConfig =        let          plugins = with pkgs.vimPlugins; [            harpoon2            luasnip

Set it up

return {    {"ThePrimeagen/harpoon",lazy=false,-- thought this would helpconfig=function()end,-- had to add this since I was getting errors if notopts= {...        },keys=function()localkeys= {...}returnkeysend,dependencies= {            {"nvim-lua/plenary.nvim"},        },    },

But I keep getting

E5108: Error executing lua: /home/nikola/.config/nvim/lua/plugins/editor.lua:26: module 'harpoon' no field package.preload'harpoon'

The plugin itself is installed

nikola in 🌐 vm in .dotfiles on  nvim [!] ➜ ls /nix/store | grep harpoona1ifppl2q77zgxfkmaf9bqcpbr5bi8gc-vimplugin-harpoon2-2024-11-13.drvms4074hlrrh01qli980cg2qv4jqbd5ig-vimplugin-harpoon2-2024-11-13

I probably have some kind of misunderstanding of the concepts involved

Same issue withluasnip that I use in mynvim-cmp

  19  /home/nikola/.config/nvim/lua/plugins/nvim-cmp.lua:13: module 'luasnip' not found:    1 > no field package.preload['luasnip']    2 > cache_loader: module 'luasnip' not found    3 > cache_loader_lib: module 'luasnip' not found    4 > no file '/nix/store/rwf92hm6drz4rgng9r2hsviqsvpwdjb7-luajit-2.1.1693350652-env/share/lua/5.1/luasnip.lua'    5 > no file '/nix/store/rwf92hm6drz4rgng9r2hsviqsvpwdjb7-luajit-2.1.1693350652-env/share/lua/5.1/luasnip/init.lua'    6 > no file '/home/nikola/.local/share/nvim/lazy-rocks/telescope.nvim/share/lua/5.1/luasnip.lua'    7 > no file '/home/nikola/.local/share/nvim/lazy-rocks/telescope.nvim/share/lua/5.1/luasnip/init.lua'    8 > no file '/nix/store/rwf92hm6drz4rgng9r2hsviqsvpwdjb7-luajit-2.1.1693350652-env/lib/lua/5.1/luasnip.so'    9 > no file '/home/nikola/.local/share/nvim/lazy-rocks/telescope.nvim/lib/lua/5.1/luasnip.so'   10 > no file '/home/nikola/.local/share/nvim/lazy-rocks/telescope.nvim/lib64/lua/5.1/luasnip.so'                                                                                                                                    │   - /nix/store/lhq9lrmdr8yrqsj0v
return {    {        "hrsh7th/nvim-cmp",        opts = function(_, opts)...            local luasnip = require("luasnip")            local cmp = require("cmp")
nikola in 🌐 vm in .dotfiles on  nvim [!] took 1m4s ➜ ls /nix/store | grep luasnipk7mbiw90g3aa8kf1w3jri78m7gkgc9hs-vimplugin-lua5.1-luasnip-2.3.0-1-unstable-2024-11-12.drvr9wmz7jw7x00mbjh5nnks4f547ng5cmm-luasnip-luarocks-config.lua.drvsw1fccdhd30ys0mm45gkmxzvnlnr9hfi-vimplugin-lua5.1-luasnip-2.3.0-1-unstable-2024-11-12zldx2lwl0g90ll1p1rd49fa5vsjmpxql-luasnip-2.3.0-1.rockspec.drv

Thanks!

Myconfig for reference

You must be logged in to vote
3 replies
@Jacobus-afk
Comment options

Hi@Nikola-Milovic, it looks like there's both aharpoon2 andluasnip extra for lazyvim

i tried it on my setup and it looks like the secret sauce is that lazyvim extras expects it to be harpoon instead of harpoon2.. it looks like the same requirement for luasnip (LuaSnip instead of luasnip)
image

after rebuilding your home manager config, go to lazy extras and enable:
image

result:
image

@Nikola-Milovic
Comment options

Thank you! Very interesting! So basically for some packages I have to update the name to match to whateverrequire("name") specifies?

@Jacobus-afk
Comment options

looks like it, if you want to use those plugins as lazy extras 😆

i think it relates to the lightblue names in Lazy extras.. maybe someone more knowledgeable can chime in

Comment options

            path = "${lazyPath}",            patterns = { "." },            -- fallback to download            fallback = true,

This is incorrect.

Despite its name, patterns does not accept patterns. It is find with plain marked as true.

To achieve the desired effect you need

            path = "${lazyPath}",            patterns = { "" },            -- fallback to download            fallback = true,

You should check out the lazy.nvim wrapper in nixCats for ideas

https://github.com/BirdeeHub/nixCats-nvim/blob/main/templates/luaUtils/lua/nixCatsUtils/lazyCat.lua

and also a demonstration of it being used to implement kickstart.nvim

https://github.com/BirdeeHub/nixCats-nvim/tree/main/templates/kickstart-nvim

You could do similar for LazyVim distro in nixCats with the wrapper, it just takes care of the boilerplate of setting those options for you and doing the RTP reset correctly.

You must be logged in to vote
2 replies
@azuwis
Comment options

            path = "${lazyPath}",            patterns = { "." },            -- fallback to download            fallback = true,

This is incorrect.

You're right. I believe the code ishttps://github.com/folke/lazy.nvim/blob/56ead98e05bb37a4ec28930a54d836d033cf00f2/lua/lazy/core/meta.lua#L219

It works by coincidence:

$ nvim --headless -c ':lua for _, plugin in ipairs(require("lazy").plugins()) do print(plugin.url) end' -c 'q'https://github.com/hrsh7th/cmp-path.githttps://github.com/nvim-lua/plenary.nvim.githttps://github.com/folke/noice.nvim.githttps://github.com/akinsho/bufferline.nvim.git...

All the plugins url contains a..

@BirdeeHub
Comment options

yes that is the code for it :)

Ah yeah that is quite funny XD

It wasnt working by accident for nixCats in the lazy.nvim wrapper, not sure why that is, although I am using the shorthand urls, but doesnt really matter "" works better and is more correct anyway

Comment options

Thanks! This script has made it possible for me to fully switch to NixOS (as Neovim + LazyVim is essential for my workflow).

One noob question: What's the difference betweenextraPackages andplugins?

You must be logged in to vote
2 replies
@BirdeeHub
Comment options

Well, plugins is a thing created directly in the code snippet you followed. extraPackages isnt, extraPackages is actually part of the module, and you can look up what it does

This takes that plugins list and makes them into a lazyPath variable which you presumeably then told lazy about.

mkEntryFromDrv=drv:iflib.isDerivationdrvthen{name="${lib.getNamedrv}";path=drv;}elsedrv;lazyPath=pkgs.linkFarm"lazy-plugins"(builtins.mapmkEntryFromDrvplugins);
@Zeta611
Comment options

Thanks! But I was talking about

plugins = with pkgs.vimPlugins; [      lazy-nvim    ];

not the one inside the let-binding, but the one for theprograms.neovim config. Or are you indeed talking about theprograms.neovim.plugins?

Comment options

For those still having issues with treesitter moaning about needing a writable parser directory, even though specifyingensure_installed = {} in your own plugin spec, the following worked for me:

  LazyVimCustom = pkgs.vimPlugins.LazyVim.overrideAttrs (oldAttrs: {    postInstall = ''      rm -f $out/lua/lazyvim/plugins/treesitter.lua    '';  });

This ensures LazyVim does not load ANY builtin treesitter defaults that would cause that error message.
You then just need to use as follows:

vimPlugins = with pkgs.vimPlugins; [    # LazyVim    LazyVimCustom...

I'm still having to import all my plugins with require, the import='plugins' just won't work as LazyVim can't find them, even though all the paths are present in the runtime paths...

You must be logged in to vote
0 replies
Comment options

Am I crazy or this just doesn't seem worth managing with nix yet? The added layers of complexity vs. benefit just don't make sense to me.

Don't get me wrong, Nix is great for a lot of things, but doesn't have to be used for everything.

You must be logged in to vote
6 replies
@minusfive
Comment options

Using lua to configure neovim and using nix to install plugins, language servers, tools and so on, is pretty much the best possible combination, and very aligned with what nix does well.

No, I get that. But is it well aligned with what Neo/LazyVim do best? I mean, a huge part of the reason to use Neo/Lazy is the ability to iterate over configuration and plugin combinations almost instantly. And the rollback/version control use cases are completely covered by LazyVim + Git (or other VCS).

I feel like by managing N/L with Nix you introduce unnecessary complexity in the middle of that quick iteration/instant feedback process without adding significant benefits. This is especially felt when you're in the middle of working and want to quickly remove some annoyance or improve experience without losing the flow.

Then again, perhaps I'm crazy.

@ck3mp3r
Comment options

I have the lua outside of the nix, I'm not a fan of writing one language in another, it makes it harder to debug in general. I'm using home-manager for basic setup and configuration. Apps like neovim etc I configure as separate flakes and profiles I install. Iterating over neovim configuration in a flake doesn't force a home-manager rebuild and running anix build or even better, anix run .#nvim in my case allows me to test really quickly. The benefit outweighs the few extra seconds I have to wait. Also, at the end of it I have a portable neovim configuration I can run on any nix enabled machine, without installation. I'm sure you are aware of these party tricks already. I think one of the issues here is that a lot of folks put everything into one home-manager setup, and iterating over small changes do take some time, rendering them cumbersome in some cases.

@minusfive
Comment options

I'm sure you are aware of these party tricks already.

You give me too much credit. I am not, just getting familiar with Nix. I have to fiddle more with this. Thanks!

@Zeta611
Comment options

I started using this approach last month, which is when I started using NixOS for my desktop. It works fine IMO. I've used LazyVim for the past few years, Vim for little more than a decade. I agree that LazyVim does not work smoothly with Nix, but I think this is the best option for now due to the functionality of LazyVim (it just works) + reproducibility of Nix. Though I believe there's a plenty big room for improvement. I guess you can check outNixvim as an alternative. I'm planning to check it out in a near future when I have some time---the nix rabbit hole has already wasted my time enough for now 🥲

@clamydo
Comment options

One way to retain the fast iteration of the nvim config (without the need tohome-manager switch after every change) is using a symlink:

home.file={".config/nvim".source=config.lib.file.mkOutOfStoreSymlink"${home.homeDirectory}/.config/home-manager/where/every/you/want/to/put/it/nvim";

Note, that there was abug in an old version of nix that prevented this from working.

Comment options

The one thing I have not gotten to work is lazyvim automatically loading config/keymaps.lua, config/options.lua and config/autocmds.lua... also import="plugins" doesn't work. However if I do require 'plugins.my-plugin' it works... and yes, all the paths have been added to runtime. Anyone else have to specify all imports manually?

You must be logged in to vote
2 replies
@ck3mp3r
Comment options

Why is lazy removing/adding paths? It prevents me from having other directory and module paths under the lua directory.,

@folke would be great if you can shed some light. I am sure I've got something wrong somewhere...

before loading lazy.nvim
Lua package.path:
/nix/store/hxcwr8j33p9m437a7jyzwbzxhsyj5dh4-luajit-2.1.1713773202-env/share/lua/5.1/?.lua
/nix/store/hxcwr8j33p9m437a7jyzwbzxhsyj5dh4-luajit-2.1.1713773202-env/share/lua/5.1/?/init.lua

Lua package.cpath:
/nix/store/hxcwr8j33p9m437a7jyzwbzxhsyj5dh4-luajit-2.1.1713773202-env/lib/lua/5.1/?.so

Neovim runtime paths:
/nix/store/yim8xc6ngdj5k55dpqcz50icrsqk0hvy-nvim-config
/nix/store/l91x39p8wr8f4zqrs3cn7frjigzf142r-lazy-plugins
/nix/store/y2jn4p3ppm4gcgxzlad5x95b6fx9kz2n-vimplugin-lazy.nvim-2024-12-07
/nix/store/x137yfpy63v4mkn68fkaj5ky8yv53xwf-neovim-unwrapped-0.10.2/share/nvim/runtime
/nix/store/x137yfpy63v4mkn68fkaj5ky8yv53xwf-neovim-unwrapped-0.10.2/lib/nvim

after loading lazy.nvim
Lua package.path:
/nix/store/hxcwr8j33p9m437a7jyzwbzxhsyj5dh4-luajit-2.1.1713773202-env/share/lua/5.1/?.lua
/nix/store/hxcwr8j33p9m437a7jyzwbzxhsyj5dh4-luajit-2.1.1713773202-env/share/lua/5.1/?/init.lua

Lua package.cpath:
/nix/store/hxcwr8j33p9m437a7jyzwbzxhsyj5dh4-luajit-2.1.1713773202-env/lib/lua/5.1/?.so

Neovim runtime paths:
/nix/store/y2jn4p3ppm4gcgxzlad5x95b6fx9kz2n-vimplugin-lazy.nvim-2024-12-07
/nix/store/x137yfpy63v4mkn68fkaj5ky8yv53xwf-neovim-unwrapped-0.10.2/share/nvim/runtime
/nix/store/x137yfpy63v4mkn68fkaj5ky8yv53xwf-neovim-unwrapped-0.10.2/lib/nvim
/Users/christian/.local/state/nvim/lazy/readme

@ck3mp3r
Comment options

I loaded LazyVim in a separate module file... and restored the config path doing the following:

local function add_to_runtimepath(config_path)  if config_path and config_path ~= "" then    vim.o.runtimepath = vim.o.runtimepath .. "," .. config_path  endendlocal status, config_path = pcall(vim.api.nvim_get_var, "config_path")if status then  add_to_runtimepath(config_path)endreturn {  {    "LazyVim/LazyVim",    opts = {      colorscheme = "Catppuccin",    },    import = "lazyvim.plugins"  },}
Comment options

            -- force enable telescope-fzf-native.nvim            { "nvim-telescope/telescope-fzf-native.nvim", enabled = true },

why enabletelescope-fzf-native.nvim, Is this necessary for nix build?

You must be logged in to vote
2 replies
@azuwis
Comment options

LazyVim check ifmake,cmake,gmake is available when startup fortelescope-fzf-native.nvim, and try to build it.

{
"nvim-telescope/telescope-fzf-native.nvim",
build= (build_cmd~="cmake")and"make"
or"cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
enabled=build_cmd~=nil,

localbuild_cmd---@typestring?
for_,cmdinipairs({"make","cmake","gmake"})do
ifvim.fn.executable(cmd)==1then
build_cmd=cmd
break
end
end

In Nix, we probably don't want this behavior, and should enable or disable it explicitly.

If you dont needtelescope-fzf-native.nvim, you can setenabled = false and removetelescope-fzf-native.nvim from plugins.

@matadaniel
Comment options

LazyVim v14 makes fzf the default picker, so this is no longer necessary unless you explicitly enable the telescope extra.

Comment options

Hello, I think use nix to manage neovim config is a bad idea. I just install neovim, nix-ld and use neovim config as separate repository is enough. If you want your neovim config in your nix config, just symlink it as I do in my confighttps://github.com/binhtran432k/dotfiles/blob/master/home/neovim.nix. And here is my LazyVim config if you want a referencehttps://github.com/binhtran432k/dotfiles/tree/master/nvim

You must be logged in to vote
9 replies
@Nikola-Milovic
Comment options

@minusfive If you get a setup with LazyVim that you're happy with, please do share it, I ended up going a different route and I would like to do something similar to what you described

@BirdeeHub
Comment options

Also if you wanted to PR a LazyVim template I'd accept it, as long as it doesn't have many customizations or use things in LazyVim that are likely to change. (The kickstart template has been fairly low maintenance and I'd love to keep that trend haha)

@matadaniel
Comment options

@minusfive Although nixCats is an awesome package manager, my module has a more narrow focus on providing the experience you described with LazyVim and Home Manager.
https://github.com/matadaniel/LazyVim-module

@PaideiaDilemma
Comment options

Also check out my comment on this thread:#1972 (comment)
Of course this method has the issue that you could potentially have some binary blob in some plugin that is not compatible with nix, but it works fine for me.

@BirdeeHub
Comment options

from what I understand, minusfive is already basically doing that paideia. nixCats is somewhat like this as well, but it takes care of including the directory for you, and with more available options, and it is much easier to pass arbitrary info from nix to lua in an organized way. In addition, things are then bundled on the derivation level meaning you can then run it via nix run from anywhere, as opposed to being tied to a home manager config.

Comment options

https://github.com/BirdeeHub/nixCats-nvim/tree/main/templates/LazyVim

^ template that achieves basically the same thing but using nixCats so that your config can be more flexible than the home manager module is

You must be logged in to vote
0 replies
Comment options

@azuwis I try your nix config, and it build successfully, but I get this error when I run nvim

Error detected while processing User Autocommands for "VeryLazy":Could not create parser dir ' /nix/store/hay4sgj4cjbz4dcbdy6ichq1mrsyj7cs-lazy-plugins/nvim-treesitter/parser ':  Vim:E739: Cannot create directory /nix/store/hay4sgj4cjbz4dcbdy6ichq1mrsyj7cs-lazy-plugins/nvim-treesitter/parser: permission denied
You must be logged in to vote
2 replies
@Jacobus-afk
Comment options

#1972 (comment)

@Gandharikos
Comment options

Thanks, very helpful. It’s due to the plugin loading order.

Comment options

Hi, appreciate this

Can anyone tell me how to install the LazyExtra packages?
Is this right?
Go to the lazyvim site, go to the "extras" package you want to install, see what config & packages it provides to Lazy.vim,
i.e. Forextras/lang/docker

{"nvim-treesitter/nvim-treesitter",opts={ensure_installed={"dockerfile"}},}
  • all the other ones
    Then add the package fromnixpkgs
    to your nix config's extrapackages

Im also now unsure how to install any new plugin (even those not provided by extras), I just did the same thing but it didn't work (with rainbow delimiters)

You must be logged in to vote
6 replies
@ck3mp3r
Comment options

I'm using nix to manage the packages and lua to manage the config. I do not use nix to manage and translate my config to lua.
Have a look at my setuphere. You can even run it from there as it is a nix flake setup.
The plugins are managedhere and loaded likethis,this,this andthis

Hope this helps.

@notjiatan
Comment options

@ck3mp3r Hi, thank you for the response, in all honestly, im pretty new to nix & I dont use flakes nor can I understand the code or how to transfer my config

Is there a way I could just transfer my LazyVim config over to nixos with little work?
I.e. with nix-ld?
If you know what libraries I have to enable to get it working, I would appreciate it

@ck3mp3r
Comment options

@notjiatan I am afraid you are going to have to do some leg work yourself here. I've given you everything I discovered myself and help from others pointing me in the right direction...

@notjiatan
Comment options

@notjiatan I am afraid you are going to have to do some leg work yourself here. I've given you everything I discovered myself and help from others pointing me in the right direction...

@ck3mp3r
Ah ok I understand, would you at least be able to brief me on how to install plugins provided by lazy.vim (the package manager) & how to get extras working
i.e.:

return {{ "HiPhish/rainbow-delimiters.nvim" },}

I read your config too see what you are doing, you added the packagevimPlugins.rainbow-delimiters-nvim to your pkgs, I have done that but I still can't get rainbow delimiters to show up

@Jacobus-afk
Comment options

Hey@notjiatan

what you're missing isthis part in@ck3mp3r's repo

what's happening is we're bypassing the part where lazyvim goes to the repo and downloads the plugin by using nix to install it for us, but then you still have to tell lazyvim to use it

there are quite a few ways to seup lazyvim using nix..@ck3mp3r and I have followed the instructions@azuwis wrote down. I strongly suggest reading through this thread. Important bits arehere and then thisupdate (caused by a treesitter breaking change i think)

so, to recap, add

extraLuaConfig=letplugins=withpkgs.vimPlugins;[rainbow-delimiters-nvim

then add a plugin file

lua/plugins/rainbow-delims.lua

return {"HiPhish/rainbow-delimiters.nvim",event= {"BufRead"},}

result
image
image

Comment options

I just installed LazyVim on Home-Manager and it works very well, like the LazyVim native I have. However when if start it withnvim . on the Home-Manager versions I get:

Error detected while processing BufReadCmd Autocommands for "oil://*":Error executing lua callback: ...ir/pack/myNeovimPackages/start/oil.nvim/lua/oil/init.lua:1019: module 'oil.keymap_util' not found:no field package.preload['oil.keymap_util']...

My native installed LazyVim has no problem with this. I tried addoil-nvim and did some poking around to no avail. I'm not ever sure what part of trying to access Oil.

You must be logged in to vote
1 reply
@nebulorum
Comment options

I just installed LazyVim on Home-Manager and it works very well, like the LazyVim native I have. However when if start it withnvim . on the Home-Manager versions I get:

Error detected while processing BufReadCmd Autocommands for "oil://*":Error executing lua callback: ...ir/pack/myNeovimPackages/start/oil.nvim/lua/oil/init.lua:1019: module 'oil.keymap_util' not found:no field package.preload['oil.keymap_util']...

My native installed LazyVim has no problem with this. I tried addoil-nvim and did some poking around to no avail. I'm not ever sure what part of trying to access Oil.

Finally discovered the problem. I had two neovim config active at the same time. This caused plugins to be loaded incorrectly.

Comment options

I've been using this for almost a year, and it works really well.
However, one thing that I noticed is that as Folke updates Lazyvim with new plugins, it is not always easy to completely replicate the latest lazyvim setup. Has anyone else experienced the same issue? Are you doing anything to keep up to date? Do you just go through the changelog and try to add/remove plugins as needed? Is there any way to make this whole process easier?

You must be logged in to vote
2 replies
@clamydo
Comment options

Yes, that's basically what I do at least. Lazy shows which plugins are installed from source and which from nixpkgs. If a plugin is added, new plugins will install - which you can see in the lazy window that pops up as well. I then go through the list and add those plugins to my flake.

It's manual but works reasonably well. Both install sources work so it is no blocker for me.

I'm curious if someone has a different workflow.

@azuwis
Comment options

I have a script that shows the different between list of plugins required by lazyvim and provided by nix:

https://github.com/azuwis/nix-config/blob/master/common/lazyvim/base/diff-plugins.sh

Comment options

I spent some time vibe coding to create a nix flake that replicates this setup.
It is working on my machine, but if anyone wants to play around with it you are more than welcome.

https://github.com/pfassina/lazyvim-nix

feel free to contribute or report any bugs that you find, and I will take a look.
The goal is for it to track the lazyvim release and update the dependencies automatically as needed.

You must be logged in to vote
2 replies
@elf-pavlik
Comment options

Does it support extending typescript lsp with vue lsp?
https://www.lazyvim.org/extras/lang/vue

Currently this issue might be breaking it#6236

@wadeduvall
Comment options

Pretty sure your AI hallucinated the existence oftree-sitter-vimdoc in your defaults treesitter grammars.

Comment options

Is that just adding vue treesitter parser and enabling it on your LSP config?If so, it should work.
On Sat, Jul 19, 2025 at 10:20 PM, elf Pavlik < ***@***.***(mailto:On Sat, Jul 19, 2025 at 10:20 PM, elf Pavlik <<a href=)> wrote: Does it support extending typescript lsp with vue lsp?https://www.lazyvim.org/extras/lang/vue — Reply to this email directly, [view it on GitHub](#1972 (reply in thread)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAOJC52PSH3TYTSZRJV7XGL3JMRJPAVCNFSM6AAAAAA7CLSO7OVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGOBSGE2DOMA). You are receiving this because you commented.Message ID: ***@***.***>
You must be logged in to vote
0 replies
Comment options

If you're like me who use NixOS and in a hurry and want to use the current LazyVim config as is, just addnix-ld to yourconfiguration.nix and add some required pkgs (gcc, nodejs, unzip, etc.) in order for LazyVim to work. I think this is the easiest way

You must be logged in to vote
2 replies
@pfassina
Comment options

If you use flakes, my plugin should replicate the current lazyvim experience with a simple lazyvim.enable = true;
https://github.com/pfassina/lazyvim-nix

@elf-pavlik
Comment options

yeah, after trying few different approaches nix-ld turned out the only approach whichjust works

Comment options

Lazy tells me to update nvim-treesitter and nvim is a bit laggy at startup. I think this might be related to the switch tomain. Has somebody of you figured out more?

You must be logged in to vote
6 replies
@clamydo
Comment options

Basically this line?https://github.com/pfassina/lazyvim-nix/blob/3efc1e659c2d62001490d1244f4d8f5afa5db44a/nix/lib/config-generation.nix#L69 That does not seem to do anything for me (not using your flake though)

@pfassina
Comment options

You might also have to disable lazy version checker. Try that, and see if it works for you.

@clamydo
Comment options

You mean likeversion = false? Or do you mean{ checker = { enabled = false, },} for lazy itself? Unfortunately, both do not hide the message either. I appreciate you answering, though!

@clamydo
Comment options

It's this line that bothers me

returnLazyVim.error("Please use `:Lazy` and update `nvim-treesitter`")

I've now replace the config attribute with my own function removing that check but curiously the message still is displayed. Previously I saw it two messages...

@pfassina
Comment options

  1. Disable Update Checker (line 48)

checker = { enabled = false },

  1. Disable Change Notifications (line 49)

change_detection = { notify = false },

  1. Add the following Treesitter Configuration
{"nvim-treesitter/nvim-treesitter",build=false,opts= {auto_install=false,ensure_installed= {},-- ... other opts  },}

If that doesn't work, I'm not sure why it is still giving you the notifications. There might be some override somewhere. You could also try the flake, and see if it works for you. You shouldn't get the notification with it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Recipes
Labels
None yet
31 participants
@azuwis@minusfive@johnallen3d@SolidRhino@cameronraysmith@ck3mp3r@JonBoyleCoding@elf-pavlik@pfassina@nebulorum@multivac61@Zeta611@wadeduvall@Gandharikos@clamydo@binhtran432k@sabitm@marcokuoni@dltompki@sylvesterroos@qlibpand others

[8]ページ先頭

©2009-2025 Movatter.jp