diff --git a/grow/default.nix b/grow/default.nix index 9bb1bd6..6f7500a 100644 --- a/grow/default.nix +++ b/grow/default.nix @@ -98,29 +98,32 @@ oPath = paths.cellBlockPath cellsFrom cellName cellBlock; isFile = l.pathExists oPath.file; isDir = l.pathExists oPath.dir; - Target' = path': Target "paisano/import: ${path'}"; # TODO: implement lazy target block type checks - import' = path': path: let + import' = {displayPath, importPath} let # since we're not really importing files within the framework # the non-memoization of scopedImport doesn't have practical penalty - block = Block "paisano/import: ${path'}" (l.scopedImport signature path); + block = Block "paisano/import: ${displayPath}" (l.scopedImport signature importPath); signature = _ImportSignatureFor res.output; # recursion on cell in if l.typeOf block == "set" then block else block signature; - imported = + importPaths = if isFile - then Target' oPath.file' (import' oPath.file' oPath.file) + then {displayPath = oPath.file'; importPath = oPath.file;} else if isDir - then Target' oPath.dir' (import' oPath.dir' oPath.dir) + then {displayPath = oPath.dir'; importPath = oPath.dir;} else throw "unreachable!"; + Target' = {displayPath, ...}: Target "paisano/import: ${displayPath}"; + imported = import' importPaths; + # type checked import + imported' = Target' importPaths ((cellBlock.__type or null) imported); # extract instatiates actions and extracts metadata for the __std registry - extracted = l.optionalAttrs (cellBlock.cli or true) (l.mapAttrs (_extract cellBlock) imported); + extracted = l.optionalAttrs (cellBlock.cli or true) (l.mapAttrs (_extract cellBlock) imported'); in optionalLoad (isFile || isDir) [ # top level output - {${cellBlock.name} = imported;} + {${cellBlock.name} = imported';} # __std.actions (slow) {${cellBlock.name} = l.mapAttrs (_: set: set.actions) extracted;} # __std.init (fast) diff --git a/types/default.nix b/types/default.nix index b492b73..0d3a56a 100644 --- a/types/default.nix +++ b/types/default.nix @@ -7,21 +7,22 @@ inherit l; inherit (paths) cellPath cellBlockPath; }; - Target = log: - with yants log; - # unfortunately eval during check can cause infinite recursions - # if blockType == "runnables" || blockType == "installables" - # then attrs drv - # else if blockType == "functions" - # then attrs function - # else throw "unreachable"; - attrs any; + Target = log: type: + with yants log; let + type' = + # TODO: remove in the future and make a specific type a hard requirement + if type == null + then any + else type; + in + attrs type'; Systems = log: with yants log; list (enum "system" l.systems.doubles.all); BlockTypes = log: with yants log; list (struct "cellBlock" { name = string; type = string; + __type = option type; __functor = option function; ci = option (attrs bool); cli = option bool;