modules: export also core modules

This commit is contained in:
DavHau 2023-10-07 13:16:56 +02:00
parent e9fac8985c
commit 88087f6b88
2 changed files with 34 additions and 1 deletions

View File

@ -46,7 +46,7 @@ in {
imports = flakePartsModules;
options.flake.modules = mkOption {
type = types.lazyAttrsOf types.raw;
type = types.lazyAttrsOf (types.lazyAttrsOf types.raw);
};
# generates future flake outputs: `modules.<kind>.<module-name>`

View File

@ -0,0 +1,33 @@
# Automatically exports modules from the `/**/modules` directory to:
# `flake.modules.<kind>.<name>`
# Automatically imports all flake-parts modules from `/**/modules/flake-parts`
{
config,
lib,
self,
...
}: let
# inherit all lib functions used below
inherit
(builtins)
readDir
;
inherit
(lib)
mapAttrs'
filterAttrs
nameValuePair
removeSuffix
;
mapModules = path:
mapAttrs'
(fn: _:
nameValuePair
(removeSuffix ".nix" fn)
(path + "/${fn}"))
(filterAttrs (_: type: type == "regular" || type == "directory") (readDir path));
in {
# generates future flake outputs: `modules.<kind>.<module-name>`
config.flake.modules.dream2nix = mapModules (self + "/modules/dream2nix/core");
}