nix-community.nixvim/lib/modules.nix
Matt Sturgeon 16662760a9
lib/modules: specify modulesPath
`specialArgs.modulesPath` can be used to allow users to manually
import modules relative to our `./modules` directory.

It is also used by the module system to provide a base path for
relative `disabledModules` paths.
2025-01-17 00:28:36 +00:00

48 lines
1.5 KiB
Nix

{
lib,
self,
flake,
}:
let
removed = {
# Removed 2024-09-24
getAssertionMessages = "";
# Removed 2024-09-27
specialArgs = "It has been integrated into `evalNixvim`";
specialArgsWith = "It has been integrated into `evalNixvim`";
# Removed 2024-12-18
applyExtraConfig = "It has been moved to `lib.plugins.utils`";
mkConfigAt = "It has been moved to `lib.plugins.utils`";
};
in
{
# Evaluate nixvim modules, checking warnings and assertions
evalNixvim =
{
modules ? [ ],
extraSpecialArgs ? { },
}:
# Ensure a suitable `lib` is used
# TODO: offer a lib overlay that end-users could use to apply nixvim's extensions to their own `lib`
assert lib.assertMsg (extraSpecialArgs ? lib -> extraSpecialArgs.lib ? nixvim) ''
Nixvim requires a lib that includes some custom extensions, however the `lib` from `specialArgs` does not have a `nixvim` attr.
Remove `lib` from nixvim's `specialArgs` or ensure you apply nixvim's extensions to your `lib`.'';
lib.evalModules {
modules = modules ++ [
../modules/top-level
{
_file = "<nixvim-flake>";
flake = lib.mkOptionDefault flake;
}
];
specialArgs = {
modulesPath = ../modules;
# TODO: deprecate `helpers`
helpers = self;
} // extraSpecialArgs;
};
}
// lib.mapAttrs (
name: msg:
throw ("`modules.${name}` has been removed." + lib.optionalString (msg != "") (" " + msg))
) removed