{ pkgs, system, inputs, config, lib, helperLib, ... }: let cfg = config.myHomeManager; # Taking all modules in ./features and adding enables to them features = helperLib.extendModules (name: { extraOptions = { myHomeManager.${name}.enable = lib.mkEnableOption "enable my ${name} configuration"; }; configExtension = config: (lib.mkIf cfg.${name}.enable config); }) (helperLib.filesIn ./features); # Taking all module bundles in ./bundles and adding bundle.enables to them bundles = helperLib.extendModules (name: { extraOptions = { myHomeManager.bundles.${name}.enable = lib.mkEnableOption "enable ${name} module bundle"; }; configExtension = config: (lib.mkIf cfg.bundles.${name}.enable config); }) (helperLib.filesIn ./bundles); in { imports = [ ] ++ features ++ bundles ; config = { myHomeManager = { bundles.core.enable = lib.mkDefault true; }; }; }