2023-10-07 14:16:56 +03:00
|
|
|
# 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)
|
|
|
|
filterAttrs
|
2023-10-12 01:03:15 +03:00
|
|
|
mapAttrs'
|
2023-10-07 14:16:56 +03:00
|
|
|
nameValuePair
|
|
|
|
removeSuffix
|
|
|
|
;
|
|
|
|
|
2023-10-12 01:03:15 +03:00
|
|
|
path = self + "/modules/dream2nix/core";
|
|
|
|
|
|
|
|
dirs = filterAttrs (name: _: name != "default.nix") (readDir path);
|
|
|
|
|
|
|
|
modules =
|
2023-10-07 14:16:56 +03:00
|
|
|
mapAttrs'
|
|
|
|
(fn: _:
|
|
|
|
nameValuePair
|
|
|
|
(removeSuffix ".nix" fn)
|
|
|
|
(path + "/${fn}"))
|
2023-10-12 01:03:15 +03:00
|
|
|
(filterAttrs (_: type: type == "regular" || type == "directory") dirs);
|
2023-10-07 14:16:56 +03:00
|
|
|
in {
|
|
|
|
# generates future flake outputs: `modules.<kind>.<module-name>`
|
2023-10-12 01:03:15 +03:00
|
|
|
config.flake.modules.dream2nix = modules;
|
2023-10-07 14:16:56 +03:00
|
|
|
}
|