Since Nix does not officially support YAML yet (NixOS/nix#7340), I created this flake which runs yq for conversions between JSON and YAML.
Such a solution is not ideal to be merged to nixpkgs, as it's based on the concept of IFD.
In flake.nix:
{
inputs = {
# ...
yaml.url = "github:jim3692/yaml.nix";
};
outputs = { yaml, ... }: {
specialArgs = {
lib = nixpkgs.lib.extend (
final: prev: { yaml = yaml.lib; }
);
# ...
};
# ...
};
}lib.yaml.fromYaml :: path -> set
Description: It takes a YAML file path as parameter and returns the resulting attrSet
lib.yaml.toYaml :: set -> path
Description: It takes an attrSet as parameter and returns the path of the generated YAML file