nvim-nix/nix/neovim-overlay.nix
2025-09-06 13:48:36 +03:00

113 lines
2.8 KiB
Nix

# This overlay, when applied to nixpkgs, adds the final neovim derivation to nixpkgs.
{ inputs }: final: prev:
with final.pkgs.lib; let
pkgs = final;
lib = final.pkgs.lib;
# Use this to create a plugin from a flake input
mkNvimPlugin = src: pname:
pkgs.vimUtils.buildVimPlugin {
inherit pname src;
version = src.lastModifiedDate;
};
# Make sure we use the pinned nixpkgs instance for wrapNeovimUnstable,
# otherwise it could have an incompatible signature when applying this overlay.
pkgs-locked = inputs.nixpkgs.legacyPackages.${pkgs.system};
# This is the helper function that builds the Neovim derivation.
mkNeovim = pkgs.callPackage ./mkNeovim.nix {
inherit (pkgs-locked) wrapNeovimUnstable neovimUtils;
};
callPackage = (file: pkgs.callPackage file {
inherit inputs pkgs mkNvimPlugin lib;
});
langs = callPackage ./lang;
# A plugin can either be a package or an attrset, such as
# { plugin = <plugin>; # the package, e.g. pkgs.vimPlugins.nvim-cmp
# config = <config>; # String; a config that will be loaded with the plugin
# # Boolean; Whether to automatically load the plugin as a 'start' plugin,
# # or as an 'opt' plugin, that can be loaded with `:packadd!`
# optional = <true|false>; # Default: false
# ...
# }
all-plugins = with pkgs.vimPlugins; [
{
plugin = lze;
optional = false;
}
{
plugin = snacks-nvim;
optional = false;
}
]
++ langs.plugins
++ (callPackage ./treesitter.nix)
++ (callPackage ./autocomplete.nix)
++ [
diffview-nvim
gitsigns-nvim
vim-fugitive
which-key-nvim
better-escape-nvim
plenary-nvim
{
plugin = mini-icons;
optional = false;
type = "lua";
config = /*lua*/''
require("mini.icons").setup()
MiniIcons.mock_nvim_web_devicons()
'';
}
{ plugin = oil-nvim; optional = false; }
];
extraPackages = langs.packages;
in
{
# This is the neovim derivation
# returned by the overlay
nvim-pkg = mkNeovim {
plugins = all-plugins;
inherit extraPackages;
};
# This is meant to be used within a devshell.
# Instead of loading the lua Neovim configuration from
# the Nix store, it is loaded from $XDG_CONFIG_HOME/nvim-dev
nvim-dev = mkNeovim {
plugins = all-plugins;
inherit extraPackages;
appName = "nvim-dev";
wrapRc = false;
};
# This can be symlinked in the devShell's shellHook
nvim-luarc-json = final.mk-luarc-json {
plugins = all-plugins;
};
# You can add as many derivations as you like.
# Use `ignoreConfigRegexes` to filter out config
# files you would not like to include.
#
# For example:
#
# nvim-pkg-no-telescope = mkNeovim {
# plugins = [];
# ignoreConfigRegexes = [
# "^plugin/telescope.lua"
# "^ftplugin/.*.lua"
# ];
# inherit extraPackages;
# };
}