diff --git a/deprecated.nix b/deprecated.nix index b45f7e4..fd90476 100644 --- a/deprecated.nix +++ b/deprecated.nix @@ -90,6 +90,14 @@ rec { ) ; + importModules = + lib.warn '' + Deprecated Function: lib.importModules. + + Use lib.importExportableModules instead to set `exportedModules` option + '' + importers'.importExportableModules; + importers = lib.warn '' Deprecated Attribute Set: lib.importers. diff --git a/doc/api-reference-devshell.md b/doc/api-reference-devshell.md index c061840..91f4a48 100755 --- a/doc/api-reference-devshell.md +++ b/doc/api-reference-devshell.md @@ -19,24 +19,7 @@ submodule or path convertible to it -## devshell.externalModules -modules to include that won't be exported -meant importing modules from external flakes - - -*_Type_*: -list of valid modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## devshell.modules +## devshell.exportedModules modules to include in all hosts and export to devshellModules output @@ -52,3 +35,38 @@ list of valid module or path convertible to its or anything convertible to it +## devshell.externalModules +ERROR: The `externalModules` option has been removed. +Any modules that should be exported should be defined with the `exportedModules` +option and all other modules should just go into the `modules` option. + + +*_Type_*: +list of valid modules or anything convertible to it or path convertible to it + + +*_Default_* +``` +[] +``` + + + + +## devshell.modules +modules to include that won't be exported +meant importing modules from external flakes + + +*_Type_*: +list of valid modules or anything convertible to it + + +*_Default_* +``` +[] +``` + + + + diff --git a/doc/api-reference-home.md b/doc/api-reference-home.md index 796d423..e2d4c45 100755 --- a/doc/api-reference-home.md +++ b/doc/api-reference-home.md @@ -18,9 +18,26 @@ submodule or path convertible to it +## home.exportedModules +modules to include in all hosts and export to homeModules output + + +*_Type_*: +list of valid modules or anything convertible to it + + +*_Default_* +``` +[] +``` + + + + ## home.externalModules -modules to include that won't be exported -meant importing modules from external flakes +ERROR: The `externalModules` option has been removed. +Any modules that should be exported should be defined with the `exportedModules` +option and all other modules should just go into the `modules` option. *_Type_*: @@ -68,7 +85,8 @@ null ## home.modules -modules to include in all hosts and export to homeModules output +modules to include that won't be exported +meant importing modules from external flakes *_Type_*: diff --git a/doc/api-reference-nixos.md b/doc/api-reference-nixos.md index adedc19..ad4e295 100755 --- a/doc/api-reference-nixos.md +++ b/doc/api-reference-nixos.md @@ -49,9 +49,26 @@ channel defined in `channels` +## nixos.hostDefaults.exportedModules +modules to include in all hosts and export to nixosModules output + + +*_Type_*: +list of valid modules or anything convertible to it + + +*_Default_* +``` +[] +``` + + + + ## nixos.hostDefaults.externalModules -modules to include that won't be exported -meant importing modules from external flakes +ERROR: The `externalModules` option has been removed. +Any modules that should be exported should be defined with the `exportedModules` +option and all other modules should just go into the `modules` option. *_Type_*: @@ -67,7 +84,8 @@ list of valid modules or anything convertible to it or path convertible to it ## nixos.hostDefaults.modules -modules to include in all hosts and export to nixosModules output +modules to include that won't be exported +meant importing modules from external flakes *_Type_*: diff --git a/examples/downstream b/examples/downstream index 079adc4..f2c363c 160000 --- a/examples/downstream +++ b/examples/downstream @@ -1 +1 @@ -Subproject commit 079adc4474231d5582fee5574bc5bcc6f133e5ac +Subproject commit f2c363cadbbd50032f0030de3a28ed8ecdd4fa42 diff --git a/examples/groupByConfig/devshell/default.nix b/examples/groupByConfig/devshell/default.nix index 46d049d..40c2d35 100644 --- a/examples/groupByConfig/devshell/default.nix +++ b/examples/groupByConfig/devshell/default.nix @@ -1,4 +1,4 @@ { self, ... }: { - modules = [ ./python.toml ]; + exportedModules = [ ./python.toml ]; } diff --git a/examples/groupByConfig/home/default.nix b/examples/groupByConfig/home/default.nix index b5f88b1..1b4c3c9 100644 --- a/examples/groupByConfig/home/default.nix +++ b/examples/groupByConfig/home/default.nix @@ -3,5 +3,5 @@ let lib = self.inputs.digga.lib; in { - imports = [ (lib.importModules ./modules) ]; + imports = [ (lib.importExportableModules ./modules) ]; } diff --git a/examples/hmOnly/home/default.nix b/examples/hmOnly/home/default.nix index cb4e821..dca6c35 100644 --- a/examples/hmOnly/home/default.nix +++ b/examples/hmOnly/home/default.nix @@ -3,8 +3,8 @@ let lib = inputs.digga.lib; in { - imports = [ (lib.importModules ./modules) ]; - externalModules = [ ]; + imports = [ (lib.importExportableModules ./modules) ]; + modules = [ ]; importables = rec { profiles = lib.rakeLeaves ./profiles; suites = with profiles; { diff --git a/flake.nix b/flake.nix index 8c5357e..a3dc9a7 100644 --- a/flake.nix +++ b/flake.nix @@ -114,7 +114,7 @@ inherit (flake-utils-plus.lib) exportModules exportOverlays exportPackages; inherit mkFlake; inherit (tests) mkTest allProfilesTest; - inherit (importers) flattenTree rakeLeaves importOverlays importModules importHosts; + inherit (importers) flattenTree rakeLeaves importOverlays importExportableModules importHosts; inherit (generators) mkDeployNodes mkHomeConfigurations; # DEPRECATED - will be removed soon @@ -124,6 +124,7 @@ mkProfileAttrs exporters modules + importModules importers ; diff --git a/src/importers.nix b/src/importers.nix index c583a4d..039ec9f 100644 --- a/src/importers.nix +++ b/src/importers.nix @@ -126,10 +126,10 @@ in overlays = lib.mkAfter (builtins.attrValues (flattenTree (rakeLeaves dir))); }; - importModules = dir: + importExportableModules = dir: { # Meant to output a module that sets the modules option - modules = builtins.attrValues (flattenTree (rakeLeaves dir)); + exportedModules = builtins.attrValues (flattenTree (rakeLeaves dir)); }; importHosts = dir: diff --git a/src/mkFlake/fup-adapter.nix b/src/mkFlake/fup-adapter.nix index ea499b8..97868fa 100644 --- a/src/mkFlake/fup-adapter.nix +++ b/src/mkFlake/fup-adapter.nix @@ -25,7 +25,7 @@ let defaultHostModules = [ (internal-modules.hmNixosDefaults { specialArgs = config.home.importables; - modules = config.home.modules ++ config.home.externalModules; + modules = config.home.modules ++ config.home.exportedModules; }) (internal-modules.globalDefaults { hmUsers = config.home.users; @@ -53,7 +53,8 @@ let # but for proper default handling in fup, null args have to be removed stripHost = args: removeAttrs (lib.filterAttrs (_: arg: arg != null) args) [ # arguments in our hosts/hostDefaults api that shouldn't be passed to fup - "externalModules" + "externalModules" # TODO: remove deprecated option + "exportedModules" "tests" ]; @@ -79,14 +80,14 @@ let hostDefaults = flake-utils-plus.lib.mergeAny (stripHost config.nixos.hostDefaults) { # add `self` & `inputs` as specialargs so their libs can be used in imports specialArgs = config.nixos.importables // { inherit (config) self inputs; }; - modules = config.nixos.hostDefaults.externalModules ++ defaultHostModules; + modules = config.nixos.hostDefaults.exportedModules ++ defaultHostModules; }; - nixosModules = flake-utils-plus.lib.exportModules config.nixos.hostDefaults.modules; + nixosModules = flake-utils-plus.lib.exportModules config.nixos.hostDefaults.exportedModules; - homeModules = flake-utils-plus.lib.exportModules config.home.modules; + homeModules = flake-utils-plus.lib.exportModules config.home.exportedModules; - devshellModules = flake-utils-plus.lib.exportModules config.devshell.modules; + devshellModules = flake-utils-plus.lib.exportModules config.devshell.exportedModules; overlays = flake-utils-plus.lib.exportOverlays { # since we can't detect overlays owned by self diff --git a/src/mkFlake/options.nix b/src/mkFlake/options.nix index 7d18f13..1bcc92f 100644 --- a/src/mkFlake/options.nix +++ b/src/mkFlake/options.nix @@ -187,9 +187,9 @@ let ''; }; - exportedModulesOpt = name: { modules = mkOption (exportedModulesOpt' name); }; + exportedModulesOpt = name: { exportedModules = mkOption (exportedModulesOpt' name); }; exportedDevshellModulesOpt = { - modules = mkOption ( + exportedModules = mkOption ( (exportedModulesOpt' "devshell") // { type = with types; devshellModulesType; } @@ -198,8 +198,8 @@ let # This is only needed for hostDefaults # modules in each host don't get exported - externalModulesOpt = { - externalModules = mkOption { + regularModulesOpt = { + modules = mkOption { type = with types; pathToOr modulesType; default = [ ]; description = '' @@ -209,6 +209,28 @@ let }; }; + externalModulesDeprecationMessage = '' + The `externalModules` option has been removed. + Any modules that should be exported should be defined with the `exportedModules` + option and all other modules should just go into the `modules` option. + ''; + legacyExternalModulesMod = { config, options, ... }: { + options = { + externalModules = mkOption { + type = with types; modulesType; + default = [ ]; + description = externalModulesDeprecationMessage; + }; + }; + config = mkIf (config.externalModules != [ ]) { + modules = throw '' + ERROR: ${externalModulesDeprecationMessage} + + Value of externalModules: ${config.externalModules} + ''; + }; + }; + hostDefaultsOpt = name: { hostDefaults = mkOption { type = with types; hostDefaultsType name; @@ -351,7 +373,8 @@ let hostDefaultsType = name: with types; submoduleWith { modules = [ - { options = systemOpt // (channelNameOpt true) // externalModulesOpt // (exportedModulesOpt name); } + { options = systemOpt // (channelNameOpt true) // regularModulesOpt // (exportedModulesOpt name); } + legacyExternalModulesMod ]; }; @@ -366,7 +389,8 @@ let homeType = with types; submoduleWith { specialArgs = { inherit self inputs; }; modules = [ - { options = externalModulesOpt // (exportedModulesOpt "home") // importablesOpt // usersOpt; } + { options = regularModulesOpt // (exportedModulesOpt "home") // importablesOpt // usersOpt; } + legacyExternalModulesMod legacyImportablesMod ]; }; @@ -374,7 +398,8 @@ let devshellType = with types; submoduleWith { specialArgs = { inherit self inputs; }; modules = [ - { options = externalModulesOpt // exportedDevshellModulesOpt; } + { options = regularModulesOpt // exportedDevshellModulesOpt; } + legacyExternalModulesMod ]; }; diff --git a/src/mkFlake/outputs-builder.nix b/src/mkFlake/outputs-builder.nix index f7bc56e..8a9f31a 100644 --- a/src/mkFlake/outputs-builder.nix +++ b/src/mkFlake/outputs-builder.nix @@ -20,7 +20,7 @@ let home-manager.lib.homeManagerConfiguration { inherit username homeDirectory pkgs system; - extraModules = config.home.modules ++ config.home.externalModules; + extraModules = config.home.modules ++ config.home.exportedModules; extraSpecialArgs = config.home.importables; configuration = { @@ -53,7 +53,7 @@ in eval = import "${devshell}/modules" pkgs; configuration = { name = lib.mkDefault config.nixos.hostDefaults.channelName; - imports = config.devshell.modules ++ config.devshell.externalModules; + imports = config.devshell.modules ++ config.devshell.exportedModules; }; in (eval {