Skip to content

devx/lazyvim-nix

 
 

Repository files navigation

lazyvim-nix

A Nix flake for LazyVim that just works

What is this?

This flake lets you use LazyVim on NixOS with minimal configuration. It automatically manages plugins and provides the full LazyVim experience without manual maintenance.

Quick Start

  1. 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
  };
}
  1. Enable LazyVim in your home-manager configuration:
{
  imports = [ lazyvim.homeManagerModules.default ];

  programs.lazyvim = {
    enable = true;
  };
}
  1. That's it! Open nvim and enjoy LazyVim.

Configuration

Adding Language Support

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
  ];
};

Customizing LazyVim

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,
      }
    '';
  };
};

How It Works

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

Differences from Regular LazyVim

  • No Mason.nvim: LSP servers and tools are installed via extraPackages
  • Treesitter parsers: Managed via treesitterParsers option
  • Plugin updates: Happen through nix flake update instead of :Lazy update

Development

Manual Updates

# 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.sh

Automated Updates

This flake includes GitHub workflows for automated maintenance:

  1. 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
  2. On-Demand Mapping Updates (update-mappings.yml)

    • Triggered manually via GitHub Actions
    • Or by commenting /update-mappings on 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

Acknowledgments

  • 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!

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Nix 48.2%
  • Lua 34.1%
  • Shell 17.7%