1
1
mirror of https://github.com/divnix/digga.git synced 2024-11-22 10:43:27 +03:00

rename current modules -> exportedModules

and externalModules -> modules
This commit is contained in:
Parthiv Seetharaman 2021-09-24 11:52:37 -07:00
parent 58354603ec
commit 0014c5d509
13 changed files with 136 additions and 47 deletions

View File

@ -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.

View File

@ -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_*
```
[]
```

View File

@ -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_*:

View File

@ -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_*:

@ -1 +1 @@
Subproject commit 079adc4474231d5582fee5574bc5bcc6f133e5ac
Subproject commit f2c363cadbbd50032f0030de3a28ed8ecdd4fa42

View File

@ -1,4 +1,4 @@
{ self, ... }:
{
modules = [ ./python.toml ];
exportedModules = [ ./python.toml ];
}

View File

@ -3,5 +3,5 @@ let
lib = self.inputs.digga.lib;
in
{
imports = [ (lib.importModules ./modules) ];
imports = [ (lib.importExportableModules ./modules) ];
}

View File

@ -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; {

View File

@ -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
;

View File

@ -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:

View File

@ -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

View File

@ -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
];
};

View File

@ -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 {