diff options
Diffstat (limited to 'pkgs/pkgs-lib/formats.nix')
-rw-r--r-- | pkgs/pkgs-lib/formats.nix | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/pkgs/pkgs-lib/formats.nix b/pkgs/pkgs-lib/formats.nix index 44c8f9135439..5e17519d4ce1 100644 --- a/pkgs/pkgs-lib/formats.nix +++ b/pkgs/pkgs-lib/formats.nix @@ -48,14 +48,31 @@ rec { }; - # YAML has been a strict superset of JSON since 1.2 - yaml = {}: - let jsonSet = json {}; - in jsonSet // { - type = jsonSet.type // { + yaml = {}: { + + generate = name: value: pkgs.runCommand name { + nativeBuildInputs = [ pkgs.remarshal ]; + 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"; }; - }; + in valueType; + + }; ini = { # Represents lists as duplicate keys |