I was getting frustrated with the options for managing Neovim config in Nix. It seemed that you either had to go all the way by nixifying your whole neovim config or just use dotfiles and manage dependencies separately. Well, not anymore!
Neonix helps you by checking ${pkgs.hello}/bin/hello like paths in your Neovim configs, installing them into a SEPARATE profile and using them. Sort of like a special HomeManager module for Neovim.
Let's say you have something like this in your nixos config folder:
- nvim/
- init.lua
- after/lsp/
- clangd.lua
- c3_lsp.lua
- configuration.nix
- user.nix
Neonix will automatically install clang/c3lsp in a new profile located at $HOME/neonix.
# clangd.lua
return {
cmd = { '${pkgs.clang-tools}/bin/clangd' },
}# c3_lsp.lua
return {
cmd = { '${pkgs-unstable.c3lsp}/bin/c3lsp' },
}# configuration.nix
home-manager.users.myUser = import ./user.nix;If you have home-manager installed, all you need to do is add the following (in your user's config):
# user.nix
imports = [
(import (builtins.fetchTarball "https://github.com/SMFloris/neonix/archive/refs/heads/master.tar.gz"))
];
programs.neonix = {
enable = true;
packageSets = {
pkgs = pkgs;
pkgs-unstable = nixpkgs-unstable;
};
nvimConfigPath = "./nvim";
nvimPackage = nixpkgs-unstable.neovim-unwrapped;
};After rebuilding with nixos-rebuild switch and launching neovim, you'll have your lsps available and not pollute the rest of your profiles or your machine.