Skip to main content

compile_module

Function compile_module 

Source
pub fn compile_module(
    label: &str,
    ast: &AstGraph,
    id: ModuleId,
) -> Result<ModuleNode, ModuleCompilerError>
Expand description

Compile one module’s AstGraph into a typed ModuleNode.

label is the caller-supplied identifier (the file path relative to the flake root is the canonical choice).

id is the module id this node will be assigned in its containing [ModuleGraph]; the compiler stamps it through so the caller can just g.push_module(compile_module(label, &ast, expected_id)?).

§Errors

ModuleCompilerError::UnexpectedRootShape if the root node is neither a lambda nor an attrset. Real NixOS modules are always one of those two shapes, so a mismatch is a content bug, not a compiler bug — caller should skip the module and surface the error to the operator.