pkgs.formats.yaml_1_2: init
Same as YAML 1.1 but relies on the unpinned remarshal version which emits YAML 1.2.
This commit is contained in:
parent
917dfafa27
commit
eb8f7fcc12
@ -192,7 +192,46 @@ optionalAttrs allowAliases aliases
|
||||
(listOf valueType)
|
||||
])
|
||||
// {
|
||||
description = "YAML value";
|
||||
description = "YAML 1.1 value";
|
||||
};
|
||||
in
|
||||
valueType;
|
||||
|
||||
};
|
||||
|
||||
yaml_1_2 =
|
||||
{ }:
|
||||
{
|
||||
generate =
|
||||
name: value:
|
||||
pkgs.callPackage (
|
||||
{ runCommand, remarshal }:
|
||||
runCommand name
|
||||
{
|
||||
nativeBuildInputs = [ remarshal ];
|
||||
value = builtins.toJSON value;
|
||||
passAsFile = [ "value" ];
|
||||
preferLocalBuild = true;
|
||||
}
|
||||
''
|
||||
json2yaml "$valuePath" "$out"
|
||||
''
|
||||
) { };
|
||||
|
||||
type =
|
||||
let
|
||||
valueType =
|
||||
nullOr (oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
path
|
||||
(attrsOf valueType)
|
||||
(listOf valueType)
|
||||
])
|
||||
// {
|
||||
description = "YAML 1.2 value";
|
||||
};
|
||||
in
|
||||
valueType;
|
||||
|
||||
@ -143,7 +143,7 @@ runBuildTests {
|
||||
};
|
||||
|
||||
yaml_1_1Atoms = shouldPass {
|
||||
format = formats.yaml { };
|
||||
format = formats.yaml_1_1 { };
|
||||
input = {
|
||||
null = null;
|
||||
false = false;
|
||||
@ -176,6 +176,40 @@ runBuildTests {
|
||||
'';
|
||||
};
|
||||
|
||||
yaml_1_2Atoms = shouldPass {
|
||||
format = formats.yaml_1_2 { };
|
||||
input = {
|
||||
null = null;
|
||||
false = false;
|
||||
true = true;
|
||||
float = 3.141;
|
||||
str = "foo";
|
||||
attrs.foo = null;
|
||||
list = [
|
||||
null
|
||||
null
|
||||
];
|
||||
path = ./testfile;
|
||||
no = "no";
|
||||
time = "22:30:00";
|
||||
};
|
||||
expected = ''
|
||||
attrs:
|
||||
foo: null
|
||||
'false': false
|
||||
float: 3.141
|
||||
list:
|
||||
- null
|
||||
- null
|
||||
no: no
|
||||
'null': null
|
||||
path: ${./testfile}
|
||||
str: foo
|
||||
time: 22:30:00
|
||||
'true': true
|
||||
'';
|
||||
};
|
||||
|
||||
iniAtoms = shouldPass {
|
||||
format = formats.ini { };
|
||||
input = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user