eval.nix: Auto-call functors as well

This makes some very cursed setup work :P
This commit is contained in:
Zhaofeng Li 2021-12-04 01:03:26 -08:00
parent 7757a0e45d
commit ddccad4fb9
2 changed files with 12 additions and 1 deletions

View file

@ -268,7 +268,7 @@ let
in hive;
rawToHive = rawHive:
if typeOf rawHive == "lambda" then rawHive {}
if typeOf rawHive == "lambda" || rawHive ? __functor then rawHive {}
else if typeOf rawHive == "set" then rawHive
else throw "The config must evaluate to an attribute set.";
in

View file

@ -427,6 +427,17 @@ fn test_hive_autocall() {
}
"#);
TempHive::valid(r#"
{
some = "value";
__functor = self: { argument ? "with default value" }: {
borg = { ... }: {
boot.isContainer = assert self.some == "value"; true;
};
};
}
"#);
TempHive::invalid(r#"
{
thisWontWork