nvim.nix/flake.nix
2025-08-14 00:54:10 -05:00

93 lines
2.6 KiB
Nix

{
description = "Neovim derivation";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/master";
flake-utils.url = "github:numtide/flake-utils";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
gen-luarc = {
url = "github:mrcjkb/nix-gen-luarc-json";
inputs.nixpkgs.follows = "nixpkgs";
};
dart = {
url = "github:iofq/dart.nvim";
flake = false;
};
nvim-treesitter = {
url = "github:nvim-treesitter/nvim-treesitter/main";
flake = false;
};
nvim-treesitter-textobjects = {
url = "github:nvim-treesitter/nvim-treesitter-textobjects/main";
flake = false;
};
# Add bleeding-edge plugins here.
# They can be updated with `nix flake update` (make sure to commit the generated flake.lock)
# wf-nvim = {
# url = "github:Cassin01/wf.nvim";
# flake = false;
# };
};
outputs =
inputs@{
self,
nixpkgs,
flake-utils,
...
}:
let
systems = builtins.attrNames nixpkgs.legacyPackages;
# This is where the Neovim derivation is built.
plugin-overlay = import ./nix/plugin-overlay.nix { inherit inputs; };
neovim-overlay = import ./nix/neovim-overlay.nix { inherit inputs; };
in
flake-utils.lib.eachSystem systems (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
inputs.neovim-nightly-overlay.overlays.default
plugin-overlay
neovim-overlay
# This adds a function can be used to generate a .luarc.json
# containing the Neovim API all plugins in the workspace directory.
# The generated file can be symlinked in the devShell's shellHook.
inputs.gen-luarc.overlays.default
];
};
shell = pkgs.mkShell {
name = "nvim-devShell";
buildInputs = with pkgs; [
lua-language-server
nil
stylua
luajitPackages.luacheck
nvim-dev
];
shellHook = ''
# symlink the .luarc.json generated in the overlay
ln -fs ${pkgs.nvim-luarc-json} .luarc.json
# allow quick iteration of lua configs
ln -Tfns $PWD/nvim ~/.config/nvim-dev
'';
};
in
{
packages = rec {
default = nvim;
nvim = pkgs.nvim-pkg;
nvim-min = pkgs.nvim-min-pkg;
nvim-dev = pkgs.nvim-dev;
};
devShells = {
default = shell;
};
}
)
// {
overlays.default = neovim-overlay;
};
}