dream2nix/modules/flake-parts/core-modules.nix
DavHau d8e4b477e3 refactor: move dev related things to /dev-flake
The goal is to reduce the flake inputs visible to the user
Still, the top-level flake re-exposes the outputs of the dev-flake, but
without exposing its inputs. This means a devShell is still available in
the top-level, for example.

This also removes the /modules/flake.nix. Its original purpose was
separating the modules inputs from the development inputs, but this is
now done the opposite way around by moving the dev inputs to
/dev-flake/flake.nix.
2023-11-05 03:42:18 +00:00

38 lines
806 B
Nix

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