A Nix flake for LazyVim that just works
This flake lets you use LazyVim on NixOS with minimal configuration. It automatically manages plugins and provides the full LazyVim experience without manual maintenance.
- Add the flake to your
flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
lazyvim.url = "github:pfassina/lazyvim-nix";
};
outputs = { nixpkgs, home-manager, lazyvim, ... }: {
# Your system configuration
};
}- Enable LazyVim in your home-manager configuration:
{
imports = [ lazyvim.homeManagerModules.default ];
programs.lazyvim = {
enable = true;
};
}- That's it! Open
nvimand enjoy LazyVim.
programs.lazyvim = {
enable = true;
# Add LSP servers and tools
extraPackages = with pkgs; [
rust-analyzer
gopls
nodePackages.typescript-language-server
];
# Add treesitter parsers
treesitterParsers = with pkgs.tree-sitter-grammars; [
tree-sitter-rust
tree-sitter-go
tree-sitter-typescript
tree-sitter-tsx
];
};Configure LazyVim using the same directory structure as a standard LazyVim setup, but directly in your Nix configuration:
programs.lazyvim = {
enable = true;
# Maps to lua/config/ directory
config = {
# Custom autocmds → lua/config/autocmds.lua
autocmds = ''
vim.api.nvim_create_autocmd("FocusLost", {
command = "silent! wa",
})
'';
# Custom keymaps → lua/config/keymaps.lua
keymaps = ''
vim.keymap.set("n", "<C-s>", "<cmd>w<cr>", { desc = "Save file" })
'';
# Custom options → lua/config/options.lua
options = ''
vim.opt.relativenumber = false
vim.opt.wrap = true
'';
};
# Maps to lua/plugins/ directory
plugins = {
# Each key becomes lua/plugins/{key}.lua
custom-theme = ''
return {
"folke/tokyonight.nvim",
opts = { style = "night", transparent = true },
}
'';
lsp-config = ''
return {
"neovim/nvim-lspconfig",
opts = function(_, opts)
opts.servers.rust_analyzer = {
settings = {
["rust-analyzer"] = {
checkOnSave = { command = "clippy" },
},
},
}
return opts
end,
}
'';
};
};This flake:
- Tracks LazyVim releases automatically
- Pre-fetches all default LazyVim plugins through Nix
- Handles Nix-specific quirks (disables Mason.nvim, manages treesitter parsers)
- Provides a clean upgrade path as LazyVim evolves
- No Mason.nvim: LSP servers and tools are installed via
extraPackages - Treesitter parsers: Managed via
treesitterParsersoption - Plugin updates: Happen through
nix flake updateinstead of:Lazy update
# Enter development shell
nix develop
# Update plugin list from LazyVim
./scripts/update-plugins.sh
# Update with nixpkgs verification (recommended)
./scripts/update-plugins.sh --verify
# Run tests
./test/test.shThis flake includes GitHub workflows for automated maintenance:
-
Daily Plugin Updates (
update-plugins.yml)- Runs daily at 2 AM UTC
- Checks for new LazyVim releases
- Creates PRs with plugin updates
- Automatically adds verified plugin mappings
-
On-Demand Mapping Updates (
update-mappings.yml)- Triggered manually via GitHub Actions
- Or by commenting
/update-mappingson a PR - Verifies and adds new plugin mappings
The workflows will:
- ✅ Verify new plugins exist in nixpkgs
- 🔄 Automatically add verified mappings
- 📋 Create PRs with detailed change summaries
- 🎯 Handle multi-module plugins correctly
- LazyVim by @folke - The amazing Neovim configuration framework that this flake packages
- This flake is heavily inspired by the setup from @azuwis. Thank you for the great foundation!
MIT