Skip to content

Support standard data format for config files (ex: JSON) #74

@ThinkChaos

Description

@ThinkChaos

Hi,

As part of migrating my mail server over to NixOS, I'm now driving chasquid's configuration files (chasquid.conf, $domain/aliases, hooks/*, etc.) from Nix code that builds-up the data in Nix native structures, like maps and arrays, and then serializes it to chasquid's expected formats.
I had to write a bit of code to generate chasquid.conf's pbtxt format, and the custom aliases format. It's nothing especially complex, but as always, less code implies less bugs, so I'd prefer to avoid it if possible!

Hence I'm wondering if you would be open to supporting a more common & standard formats in addition to the current ones?
I saw the protoc generated Config struct already includes json tags, so it should be easy to parse that, but I would understand if you'd rather not support multiple data formats.
I've already got the serialization working, so I'm totally fine if the answer is no, but I figured I might as well ask.

For the pbtxt format, I could not find any tool online that generates it as chasquid expects, and even tried writing my own in Go, but I always ended up with output like message Config { <key: value\n ... > } instead of just <key: value \n ...> at the top level.
(I expect it would work if I had used the Protobuf schema, but I wanted to avoid that so the solution would work for any input and generate any expected schema, which is how JSON/YAML/etc. serialization is handled in NixOS).

(None of the Nix stuff is public ATM, but I'm considering upstreaming the package and config module in NixOS once I'm happy with it)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions