modules: refactor module bootstrapping

Let's simplify things by defining all modules in `./plugins`, `./modules`
and `./wrappers/modules`.

Instead of currying `pkgs` into a bootstrapping module, we can require
`defaultPkgs` be provided as a special arg.

This refactor allows us to completely remove `flake-modules/modules.nix`!
This commit is contained in:
Matt Sturgeon 2024-07-02 13:30:29 +01:00
parent 3d96960348
commit d2afb176ff
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
16 changed files with 129 additions and 159 deletions

View file

@ -1,8 +1,4 @@
{
rawModules,
helpers,
pkgs,
}:
{ helpers, pkgs }:
let
# Extend nixpkg's lib, so that we can handle recursive leaf types such as `either`
lib = pkgs.lib.extend (
@ -68,6 +64,7 @@ let
};
topLevelModules = [
../modules
../wrappers/modules/output.nix
# Fake module to avoid a duplicated documentation
(lib.setDefaultModuleLocation "${nixvimPath}/wrappers/modules/files.nix" {
@ -85,7 +82,7 @@ let
};
};
})
] ++ (rawModules pkgsDoc);
];
hmOptions = builtins.removeAttrs (lib.evalModules {
modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ];
@ -97,7 +94,10 @@ rec {
inherit
(lib.evalModules {
modules = topLevelModules;
specialArgs.helpers = helpers;
specialArgs = {
inherit helpers;
defaultPkgs = pkgsDoc;
};
})
options
;

View file

@ -12,7 +12,8 @@ let
options = lib.evalModules {
inherit modules;
specialArgs = {
inherit pkgs lib helpers;
inherit helpers;
defaultPkgs = pkgs;
};
};