It depends what version of YAML you need. You may use a piece of simple code like this one (feel free to use under the nixpkgs license; EDIT: newer version here). That was to generate it directly. It may be fine for your case to use a build-time convertor, as suggested above, or some other way.