JonBoyleCoding/lazyvim-nix

This flake provides a bleeding edge LazyVim home-manager module, allowing you to install and configure LazyVim declaratively on NixOS. It tracks LazyVim releases automatically, and uses the latest plugin versions at the time of a LazyVim release.

โ˜… 0Forks 0NixGitHub โ†—Compare

README

lazyvim-nix

A bleeding edge Nix flake for LazyVim that automatically tracks LazyVim releases and provides zero-configuration setup for NixOS and home-manager users.

๐Ÿš€ Always up-to-date: Automatically tracks LazyVim releases and uses the latest plugin versions at the time of each LazyVim release.

Documentation

Quick Start

Add to your flake inputs:

{
  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 in your home-manager configuration:

{
  imports = [ lazyvim.homeManagerModules.default ];
  programs.lazyvim.enable = true;
}

That's it! Open nvim and enjoy LazyVim.

Version Pinning

Pin to a specific LazyVim release:

lazyvim.url = "github:pfassina/lazyvim-nix/v15.13.0";  # Pin to v15.13.0

Basic Configuration

Language Support

programs.lazyvim = {
  enable = true;

  extras = {
    lang.nix.enable = true;
    lang.python = {
      enable = true;
      installDependencies = true;        # Install ruff
      installRuntimeDependencies = true; # Install python3
    };
    lang.go = {
      enable = true;
      installDependencies = true;        # Install gopls, gofumpt, etc.
      installRuntimeDependencies = true; # Install go compiler
    };
  };

  # Additional packages (optional)
  extraPackages = with pkgs; [
    nixd       # Nix LSP
    alejandra  # Nix formatter
  ];

  # Only needed for languages not covered by LazyVim extras
  treesitterParsers = with pkgs.vimPlugins.nvim-treesitter-parsers; [
    wgsl      # WebGPU Shading Language
    templ     # Go templ files
  ];
};

Note: Treesitter grammars are installed automatically based on enabled language extras.

Dependency Control

Control which packages get installed automatically:

programs.lazyvim = {
  enable = true;

  # Core LazyVim dependencies (git, ripgrep, fd, etc.)
  installCoreDependencies = true;  # default: true

  extras = {
    lang.typescript = {
      enable = true;
      installDependencies = false;        # Skip typescript tools
      installRuntimeDependencies = true;  # But install nodejs
    };
  };
};

Note: Dependencies are opt-in per language. Set to false to manage packages manually via extraPackages.

โš ๏ธ Experimental: Automatic dependency installation is experimental and might not cover all required packages. Use extraPackages for missing dependencies.

Custom Configuration

Option 1: Inline Configuration

programs.lazyvim = {
  enable = true;

  config = {
    options = ''
      vim.opt.relativenumber = false
      vim.opt.wrap = true
    '';

    keymaps = ''
      vim.keymap.set("n", "<leader>w", "<cmd>w<cr>", { desc = "Save" })
    '';
  };

  plugins = {
    colorscheme = ''
      return {
        "catppuccin/nvim",
        opts = { flavour = "mocha" },
      }
    '';
  };
};

Plugin specs can also be written as Nix attrsets instead of Lua strings, using the lazyConfig helper from the flake's lib output:

programs.lazyvim.plugins = {
  colorscheme = inputs.lazyvim-nix.lib.lazyConfig {
    plugin = "catppuccin/nvim";
    opts = { flavour = "mocha"; };
  };

  # A list generates multiple specs in one file; embed Lua code
  # (e.g. functions) with lib.generators.mkLuaInline from nixpkgs
  editor = inputs.lazyvim-nix.lib.lazyConfig [
    { plugin = "neovim/nvim-lspconfig"; opts.servers.nixd = { }; }
    { plugin = "folke/noice.nvim";
      opts.routes = lib.generators.mkLuaInline "function() return my_routes end"; }
  ];
};

This works anywhere a Lua string is expected, including extras config overrides.

Option 2: File-based Configuration

For larger configurations, you can organize your LazyVim config files in a directory:

programs.lazyvim = {
  enable = true;
  configFiles = ./my-lazyvim-config;
};

Directory structure:

my-lazyvim-config/
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ keymaps.lua
โ”‚   โ”œโ”€โ”€ options.lua
โ”‚   โ””โ”€โ”€ autocmds.lua
โ””โ”€โ”€ plugins/
    โ”œโ”€โ”€ colorscheme.lua
    โ”œโ”€โ”€ lsp-config.lua
    โ””โ”€โ”€ editor.lua

Note: You can mix configFiles with inline config and plugins options, but you cannot configure the same file in both places. For example, if configFiles contains config/keymaps.lua, you cannot also set config.keymaps.

Key Features

  • ๐Ÿš€ Always up-to-date - Automatically tracks LazyVim releases with latest plugin versions
  • โœ… Zero-configuration setup - Just enable and go
  • ๐Ÿค– Reproducible builds - Core and Extra LazyVim plugins locked and in dev mode.

Documentation

๐Ÿ“– Getting Started - Complete setup guide

โš™๏ธ Configuration Reference - Module options and configuration

๐ŸŽฏ LazyVim Extras - Language and feature support

๐Ÿ”ง Plugin Sourcing Strategy - How plugins are resolved and managed

๐Ÿšจ Troubleshooting - Common issues and solutions

Updating

nix flake update          # Update to latest LazyVim
home-manager switch       # Apply changes

Acknowledgments

License

MIT

Contributors

pfassinacameronraysmithankarhemaw1cksCodys-WrightjtnuttallJonBoyleCodingdacid44github-actions[bot]phucisstupidstarbaser

Issues