I have the following home manager structure. The root file of configuration is like this:
{
pkgs,
config,
lib,
...
}: {
programs = import ./programs {inherit pkgs config lib;};
home = {
stateVersion = "23.11";
};
}
The default.nix file inside programs directory goes like this:
{
pkgs,
config,
lib,
...
}: {
# So basically, I want to split my config as much as possible. Especially with large configurations like neovim
neovim = import ./neovim {inherit pkgs config lib;};
alacritty = import ./alacritty {inherit pkgs config lib;};
wezterm = import ./wezterm {inherit pkgs config lib;};
tmux = import ./tmux {inherit pkgs config lib;};
zsh = {
enable = true;
};
}
And finally, I have a default.nix file inside neovim directory that is like this
{
pkgs,
config,
lib,
...
}: {
# This is the place where I try to split my config assuming this will work as nixos module
imports = [./plugins/lsp];
enable = true;
plugins = with pkgs.vimUtils;
with pkgs.vimPlugins; [
nvim-spectre
# .
# .
# .
# Really long list of plugins which I want to split
];
extraPackages = with pkgs; [
helm-ls # Helm language server
# .
# .
# .
# Really long list of packages which I want to split
];
}
And the default.nix file inside plugins/lsp folder which holds all lsp related configuration
{
config,
pkgs,
...
}: {
plugins = with pkgs.vimPlugins; [
{
plugin = nvim-lspconfig;
type = "lua";
config = builtins.readFile ./plugins/nvim_lspconfig.lua;
}
];
}
But this throws following error error: The option `home-manager.users.denis.programs.neovim.imports' does not exist.
Which is true. At first, I assumed by just writing imports attribute it will just work as nixos module system but I was wrong. I did a bit of research about how nixos evaluates modules, find about config.system.build.toplevel and lib.evalModules but I wasn’t able to use them nor understand. Summarizing my question how to use import function when also recursively go over all imports attributes and finally merging everything into one attribute set?