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 = {
nixos = {
overlays = nixos.lib.flatten [
overlays = [
(devos.lib.pathsIn ./overlays)
./pkgs/default.nix
pkgs.overlay # for `srcs`

View File

@ -21,6 +21,12 @@ let
inherit (submodule { }) check;
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 // {
check = builtins.isFunction;
description = "valid Nixpkgs overlay";
@ -37,7 +43,7 @@ let
pathToListOf = elemType: with types; pathTo (listOf elemType);
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 */
@ -52,7 +58,7 @@ let
'';
};
overlays = mkOption {
type = pathToListOf overlayType;
type = coercedListOf overlayType;
default = [ ];
description = escape [ "<" ">" ] ''
overlays to apply to this channel
@ -126,10 +132,7 @@ let
exportModulesModule = name: {
options = {
modules = mkOption {
type = with types; pathToListOf
# 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)));
type = with types; pathTo (coercedListOf exportModuleType);
default = [ ];
description = ''
modules to include in all hosts and export to ${name}Modules output