blob: 533cf6c177636ad6df039a13836f4b8fcf93f88a [file] [log] [blame]
Skyler Grey51e18512022-08-20 12:24:19 +01001# As our modules have nonstandard properties, we need to have some way of
2# properly intepreting them
3# This function takes a list of modules, as well as arguments to import them
4# with, and returns a list of modules, each with the standard NixOS module
5# properties as well as with custom properties as described in /README.md
6modules: args: let
7 resolver = module: let
8 importedModule =
9 if builtins.typeOf module == "path"
10 then import module
11 else module;
12 resolvedModule =
13 if builtins.typeOf importedModule == "lambda"
14 then
15 resolvedModule
16 args
17 else resolvedModule;
18 in {
19 home = module.home or {};
20 module = {
21 module.config or {};
22 module.imports or {};
23 module.options or {};
24 };
25 };
26in (
27 if modules.typeOf == "list"
28 then builtins.map resolver modules
29 else (resolver modules)
30)