mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
lib.formats.yaml: use well known YAML format
The way `(lib.formats.yaml {}).generate` generates YAML is compliant because on YAML 1.2 spec JSON is a subset of YAML but it bugs people's minds and can lead to problems with software that is not compatible with YAML 1.2. This commit also changes the test of the generation function. Data validation/typing remains the same. See #133802. Signed-off-by: lucasew <lucas59356@gmail.com>
This commit is contained in:
parent
346d5ce8a0
commit
83514ae7a9
@ -1058,6 +1058,13 @@ Superuser created successfully.
|
|||||||
sign OCSP responses and server certificates.
|
sign OCSP responses and server certificates.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<literal>lib.formats.yaml</literal>’s
|
||||||
|
<literal>generate</literal> will not generate JSON anymore,
|
||||||
|
but instead use more of the YAML-specific syntax.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
@ -302,3 +302,5 @@ To be able to access the web UI this port needs to be opened in the firewall.
|
|||||||
- Zfs: `latestCompatibleLinuxPackages` is now exported on the zfs package. One can use `boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;` to always track the latest compatible kernel with a given version of zfs.
|
- Zfs: `latestCompatibleLinuxPackages` is now exported on the zfs package. One can use `boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;` to always track the latest compatible kernel with a given version of zfs.
|
||||||
|
|
||||||
- Nginx will use the value of `sslTrustedCertificate` if provided for a virtual host, even if `enableACME` is set. This is useful for providers not using the same certificate to sign OCSP responses and server certificates.
|
- Nginx will use the value of `sslTrustedCertificate` if provided for a virtual host, even if `enableACME` is set. This is useful for providers not using the same certificate to sign OCSP responses and server certificates.
|
||||||
|
|
||||||
|
- `lib.formats.yaml`'s `generate` will not generate JSON anymore, but instead use more of the YAML-specific syntax.
|
||||||
|
@ -48,14 +48,31 @@ rec {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# YAML has been a strict superset of JSON since 1.2
|
yaml = {}: {
|
||||||
yaml = {}:
|
|
||||||
let jsonSet = json {};
|
generate = name: value: pkgs.runCommand name {
|
||||||
in jsonSet // {
|
nativeBuildInputs = [ pkgs.remarshal ];
|
||||||
type = jsonSet.type // {
|
value = builtins.toJSON value;
|
||||||
|
passAsFile = [ "value" ];
|
||||||
|
} ''
|
||||||
|
json2yaml "$valuePath" "$out"
|
||||||
|
'';
|
||||||
|
|
||||||
|
type = with lib.types; let
|
||||||
|
valueType = nullOr (oneOf [
|
||||||
|
bool
|
||||||
|
int
|
||||||
|
float
|
||||||
|
str
|
||||||
|
path
|
||||||
|
(attrsOf valueType)
|
||||||
|
(listOf valueType)
|
||||||
|
]) // {
|
||||||
description = "YAML value";
|
description = "YAML value";
|
||||||
};
|
};
|
||||||
};
|
in valueType;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
ini = {
|
ini = {
|
||||||
# Represents lists as duplicate keys
|
# Represents lists as duplicate keys
|
||||||
|
@ -72,21 +72,17 @@ in runBuildTests {
|
|||||||
path = ./formats.nix;
|
path = ./formats.nix;
|
||||||
};
|
};
|
||||||
expected = ''
|
expected = ''
|
||||||
{
|
attrs:
|
||||||
"attrs": {
|
foo: null
|
||||||
"foo": null
|
'false': false
|
||||||
},
|
float: 3.141
|
||||||
"false": false,
|
list:
|
||||||
"float": 3.141,
|
- null
|
||||||
"list": [
|
- null
|
||||||
null,
|
'null': null
|
||||||
null
|
path: ${./formats.nix}
|
||||||
],
|
str: foo
|
||||||
"null": null,
|
'true': true
|
||||||
"path": "${./formats.nix}",
|
|
||||||
"str": "foo",
|
|
||||||
"true": true
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user