forked from DGNum/colmena
eval.nix: Support autocall for hive configuration
This commit is contained in:
parent
7cc6552ee3
commit
37b43cd6d7
2 changed files with 34 additions and 6 deletions
|
@ -256,13 +256,18 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
uncheckedHive = let
|
||||
flakeToHive = flakeUri: let
|
||||
flake = builtins.getFlake flakeUri;
|
||||
hive = if flake.outputs ? colmena then flake.outputs.colmena else throw "Flake must define outputs.colmena.";
|
||||
in hive;
|
||||
|
||||
uncheckedHive =
|
||||
if rawHive != null then rawHive
|
||||
rawToHive = rawHive:
|
||||
if typeOf rawHive == "lambda" then rawHive {}
|
||||
else if typeOf rawHive == "set" then rawHive
|
||||
else throw "The config must evaluate to an attribute set.";
|
||||
in
|
||||
if rawHive != null then rawToHive rawHive
|
||||
else if flakeUri != null then flakeToHive flakeUri
|
||||
else throw "Either an attribute set or a flake URI must be specified.";
|
||||
|
||||
|
|
|
@ -405,3 +405,26 @@ fn test_meta_special_args() {
|
|||
}
|
||||
"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hive_autocall() {
|
||||
TempHive::valid(r#"
|
||||
{
|
||||
argument ? "with default value"
|
||||
}: {
|
||||
borg = { ... }: {
|
||||
boot.isContainer = true;
|
||||
};
|
||||
}
|
||||
"#);
|
||||
|
||||
TempHive::invalid(r#"
|
||||
{
|
||||
thisWontWork
|
||||
}: {
|
||||
borg = { ... }: {
|
||||
boot.isContainer = true;
|
||||
};
|
||||
}
|
||||
"#);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue