mirror of
https://github.com/NixOS/nix
synced 2024-10-18 00:16:11 -04:00
add special case for stream with one document
This commit is contained in:
parent
54fef9510c
commit
086eedf3fb
|
@ -85,7 +85,7 @@ static RegisterPrimOp primop_fromYAML({
|
|||
.name = "__fromYAML",
|
||||
.args = {"e"},
|
||||
.doc = R"(
|
||||
Convert a YAML string to a Nix value, if a conversion is possible. For example,
|
||||
Convert a YAML 1.2 string to a Nix value, if a conversion is possible. For example,
|
||||
|
||||
```nix
|
||||
builtins.fromYAML ''{x: [1, 2, 3], y: !!str null, z: null}''
|
||||
|
@ -109,7 +109,10 @@ static RegisterPrimOp primop_fromYAML({
|
|||
auto tree = parser.parse_in_arena({}, ryml::csubstr(yaml.begin(), yaml.size()));
|
||||
tree.resolve(); // resolve references
|
||||
|
||||
visitYAMLNode(context, val, tree.rootref());
|
||||
auto root = tree.rootref();
|
||||
if (root.is_stream() && root.num_children() == 1)
|
||||
root = root.child(0);
|
||||
visitYAMLNode(context, val, root);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue