Skip to content

aorith/neovim-flake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aorith's Neovim Flake

This flake packages Neovim with my custom configuration, including tools, linters, and LSP binaries using Nix/nixpkgs. It does also work without Nix, since I use it on machines that do not have or cannot install Nix. The Nix wrapper sets an environment variable (NVIM_NIX=1). If this variable is present, the Nix-specific Lua configuration is loaded.

It does not manage all the plugins with Nix, only the ones that break on NixOS are installed with it, like treesitter and its parsers, everything else is managed using mini.deps.

With Nix

It has two flavours, both of them set the variable NVIM_APPNAME to nvim-nix (the nvim wrapper does):

  • #default: neovim configuration is copied over to the nix-store, and you can run it on any machine with Nix without symlinking it to ~/.config/nvim
  • #vanilla: neovim configuration is loaded from ~/.config/$NVIM_APPNAME, this is what I usually use as it allows modifying the config on the fly, it also means that I can use the same config on systems without nix. This requires an extra step: execute ./link.sh as part of the bootstrap to link the config on a new machine

Folder Structure

  • nvim/: Contains the standard Neovim configuration files, similar to what you would find in ~/.config/nvim.
  • nix/neovim.nix: Builds the actual package and sets the required environment vars so Neovim can find the tools/linters and plugins.
  • nix/plugins.nix: Plugins to be included in the configuration, either from nixpkgs or as flake inputs.
  • nix/packages.nix: Extra packages that will be made available in Neovim's $PATH.

Execution options

# One shot
nix run github:aorith/neovim-flake#default
nix run github:aorith/neovim-flake#vanilla

# Development
nix run /path/to/your/local/neovim-flake#default
nix run /path/to/your/local/neovim-flake#vanilla

Installation

Nix Profile

# Remote install
nix profile add github:aorith/neovim-flake#default
# or
nix profile add github:aorith/neovim-flake#vanilla

# Using a local clone of this repository
nix profile add /path/to/neovim-flake/#default
# or
nix profile add /path/to/neovim-flake/#vanilla

To update, first find the profile number associated with it using nix profile list, and then use nix profile upgrade with the profile number:

nix profile list # Find the name for this flake
# Assuming the name is 'vanilla'
nix profile upgrade 'vanilla'
# Or upgrade everything
nix profile upgrade --all

NixOS

Add the flake and the package to environment.systemPackages. Either default or vanilla, here's an example:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    neovim-flake.url = "github:aorith/neovim-flake";
    # ...
  };

  outputs = inputs: {
    nixosConfigurations = {
      trantor = inputs.nixpkgs.lib.nixosSystem
      # ...
        {
          # ...
          modules = [
            ({inputs, ...}: {environment.systemPackages = [inputs.neovim-flake.packages.${system}.default];})
          ];
        };
    };
  };
}

Home Manager

Same thing as with NixOS but under home.packages:

home.packages = [ inputs.neovim-flake.packages.${pkgs.system}.default ];

About

Neovim configuration using a nix flake

Topics

Resources

License

Stars

Watchers

Forks