1
1
mirror of https://github.com/divnix/digga.git synced 2024-09-11 06:55:55 +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 = importers =
lib.warn '' lib.warn ''
Deprecated Attribute Set: lib.importers. Deprecated Attribute Set: lib.importers.

View File

@ -19,24 +19,7 @@ submodule or path convertible to it
## devshell.externalModules ## devshell.exportedModules
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
modules to include in all hosts and export to devshellModules output 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 ## home.externalModules
modules to include that won't be exported ERROR: The `externalModules` option has been removed.
meant importing modules from external flakes 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_*: *_Type_*:
@ -68,7 +85,8 @@ null
## home.modules ## 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_*: *_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 ## nixos.hostDefaults.externalModules
modules to include that won't be exported ERROR: The `externalModules` option has been removed.
meant importing modules from external flakes 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_*: *_Type_*:
@ -67,7 +84,8 @@ list of valid modules or anything convertible to it or path convertible to it
## nixos.hostDefaults.modules ## 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_*: *_Type_*:

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

View File

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

View File

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

View File

@ -3,8 +3,8 @@ let
lib = inputs.digga.lib; lib = inputs.digga.lib;
in in
{ {
imports = [ (lib.importModules ./modules) ]; imports = [ (lib.importExportableModules ./modules) ];
externalModules = [ ]; modules = [ ];
importables = rec { importables = rec {
profiles = lib.rakeLeaves ./profiles; profiles = lib.rakeLeaves ./profiles;
suites = with profiles; { suites = with profiles; {

View File

@ -114,7 +114,7 @@
inherit (flake-utils-plus.lib) exportModules exportOverlays exportPackages; inherit (flake-utils-plus.lib) exportModules exportOverlays exportPackages;
inherit mkFlake; inherit mkFlake;
inherit (tests) mkTest allProfilesTest; inherit (tests) mkTest allProfilesTest;
inherit (importers) flattenTree rakeLeaves importOverlays importModules importHosts; inherit (importers) flattenTree rakeLeaves importOverlays importExportableModules importHosts;
inherit (generators) mkDeployNodes mkHomeConfigurations; inherit (generators) mkDeployNodes mkHomeConfigurations;
# DEPRECATED - will be removed soon # DEPRECATED - will be removed soon
@ -124,6 +124,7 @@
mkProfileAttrs mkProfileAttrs
exporters exporters
modules modules
importModules
importers importers
; ;

View File

@ -126,10 +126,10 @@ in
overlays = lib.mkAfter (builtins.attrValues (flattenTree (rakeLeaves dir))); overlays = lib.mkAfter (builtins.attrValues (flattenTree (rakeLeaves dir)));
}; };
importModules = dir: importExportableModules = dir:
{ {
# Meant to output a module that sets the modules option # Meant to output a module that sets the modules option
modules = builtins.attrValues (flattenTree (rakeLeaves dir)); exportedModules = builtins.attrValues (flattenTree (rakeLeaves dir));
}; };
importHosts = dir: importHosts = dir:

View File

@ -25,7 +25,7 @@ let
defaultHostModules = [ defaultHostModules = [
(internal-modules.hmNixosDefaults { (internal-modules.hmNixosDefaults {
specialArgs = config.home.importables; specialArgs = config.home.importables;
modules = config.home.modules ++ config.home.externalModules; modules = config.home.modules ++ config.home.exportedModules;
}) })
(internal-modules.globalDefaults { (internal-modules.globalDefaults {
hmUsers = config.home.users; hmUsers = config.home.users;
@ -53,7 +53,8 @@ let
# but for proper default handling in fup, null args have to be removed # but for proper default handling in fup, null args have to be removed
stripHost = args: removeAttrs (lib.filterAttrs (_: arg: arg != null) args) [ stripHost = args: removeAttrs (lib.filterAttrs (_: arg: arg != null) args) [
# arguments in our hosts/hostDefaults api that shouldn't be passed to fup # arguments in our hosts/hostDefaults api that shouldn't be passed to fup
"externalModules" "externalModules" # TODO: remove deprecated option
"exportedModules"
"tests" "tests"
]; ];
@ -79,14 +80,14 @@ let
hostDefaults = flake-utils-plus.lib.mergeAny (stripHost config.nixos.hostDefaults) { hostDefaults = flake-utils-plus.lib.mergeAny (stripHost config.nixos.hostDefaults) {
# add `self` & `inputs` as specialargs so their libs can be used in imports # add `self` & `inputs` as specialargs so their libs can be used in imports
specialArgs = config.nixos.importables // { inherit (config) self inputs; }; 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 { overlays = flake-utils-plus.lib.exportOverlays {
# since we can't detect overlays owned by self # 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 = { exportedDevshellModulesOpt = {
modules = mkOption ( exportedModules = mkOption (
(exportedModulesOpt' "devshell") // { (exportedModulesOpt' "devshell") // {
type = with types; devshellModulesType; type = with types; devshellModulesType;
} }
@ -198,8 +198,8 @@ let
# This is only needed for hostDefaults # This is only needed for hostDefaults
# modules in each host don't get exported # modules in each host don't get exported
externalModulesOpt = { regularModulesOpt = {
externalModules = mkOption { modules = mkOption {
type = with types; pathToOr modulesType; type = with types; pathToOr modulesType;
default = [ ]; default = [ ];
description = '' 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: { hostDefaultsOpt = name: {
hostDefaults = mkOption { hostDefaults = mkOption {
type = with types; hostDefaultsType name; type = with types; hostDefaultsType name;
@ -351,7 +373,8 @@ let
hostDefaultsType = name: with types; submoduleWith { hostDefaultsType = name: with types; submoduleWith {
modules = [ 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 { homeType = with types; submoduleWith {
specialArgs = { inherit self inputs; }; specialArgs = { inherit self inputs; };
modules = [ modules = [
{ options = externalModulesOpt // (exportedModulesOpt "home") // importablesOpt // usersOpt; } { options = regularModulesOpt // (exportedModulesOpt "home") // importablesOpt // usersOpt; }
legacyExternalModulesMod
legacyImportablesMod legacyImportablesMod
]; ];
}; };
@ -374,7 +398,8 @@ let
devshellType = with types; submoduleWith { devshellType = with types; submoduleWith {
specialArgs = { inherit self inputs; }; specialArgs = { inherit self inputs; };
modules = [ modules = [
{ options = externalModulesOpt // exportedDevshellModulesOpt; } { options = regularModulesOpt // exportedDevshellModulesOpt; }
legacyExternalModulesMod
]; ];
}; };

View File

@ -20,7 +20,7 @@ let
home-manager.lib.homeManagerConfiguration { home-manager.lib.homeManagerConfiguration {
inherit username homeDirectory pkgs system; inherit username homeDirectory pkgs system;
extraModules = config.home.modules ++ config.home.externalModules; extraModules = config.home.modules ++ config.home.exportedModules;
extraSpecialArgs = config.home.importables; extraSpecialArgs = config.home.importables;
configuration = { configuration = {
@ -53,7 +53,7 @@ in
eval = import "${devshell}/modules" pkgs; eval = import "${devshell}/modules" pkgs;
configuration = { configuration = {
name = lib.mkDefault config.nixos.hostDefaults.channelName; name = lib.mkDefault config.nixos.hostDefaults.channelName;
imports = config.devshell.modules ++ config.devshell.externalModules; imports = config.devshell.modules ++ config.devshell.exportedModules;
}; };
in in
(eval { (eval {