auto-flatten coercedListOf and type fixes

This commit is contained in:
Pacman99 2021-04-27 09:35:44 -07:00
parent f57840d723
commit e67b49c280
2 changed files with 10 additions and 7 deletions

View File

@ -41,7 +41,7 @@
channels = { channels = {
nixos = { nixos = {
overlays = nixos.lib.flatten [ overlays = [
(devos.lib.pathsIn ./overlays) (devos.lib.pathsIn ./overlays)
./pkgs/default.nix ./pkgs/default.nix
pkgs.overlay # for `srcs` pkgs.overlay # for `srcs`

View File

@ -21,6 +21,12 @@ let
inherit (submodule { }) check; inherit (submodule { }) check;
description = "valid module"; description = "valid module";
}); });
# to export modules we need paths to get the name
exportModuleType = with types;
(addCheck path (x: moduleType.check (import x))) // {
description = "path to a module";
};
overlayType = pathTo (types.anything // { overlayType = pathTo (types.anything // {
check = builtins.isFunction; check = builtins.isFunction;
description = "valid Nixpkgs overlay"; description = "valid Nixpkgs overlay";
@ -37,7 +43,7 @@ let
pathToListOf = elemType: with types; pathTo (listOf elemType); pathToListOf = elemType: with types; pathTo (listOf elemType);
coercedListOf = elemType: with types; coercedListOf = elemType: with types;
coercedTo elemType (x: flatten (singleton x)) (listOf elemType); coercedTo anything (x: flatten (singleton x)) (listOf elemType);
/* Submodules needed for API containers */ /* Submodules needed for API containers */
@ -52,7 +58,7 @@ let
''; '';
}; };
overlays = mkOption { overlays = mkOption {
type = pathToListOf overlayType; type = coercedListOf overlayType;
default = [ ]; default = [ ];
description = escape [ "<" ">" ] '' description = escape [ "<" ">" ] ''
overlays to apply to this channel overlays to apply to this channel
@ -126,10 +132,7 @@ let
exportModulesModule = name: { exportModulesModule = name: {
options = { options = {
modules = mkOption { modules = mkOption {
type = with types; pathToListOf type = with types; pathTo (coercedListOf exportModuleType);
# check if the path evaluates to a proper module
# but this must be a path for the export to work
(addCheck path (x: moduleType.check (import x)));
default = [ ]; default = [ ];
description = '' description = ''
modules to include in all hosts and export to ${name}Modules output modules to include in all hosts and export to ${name}Modules output