Unable to parse nixpkgs-generated TOML
I have recently been experimenting with generating configuration files using nixago and decided to try it out for my nvfetcher.toml. However, the TOML output by the nixpkgs generator is not able to be parsed by the tool. Here's a quick repro on the REPL (assuming pkgs is in scope):
nix-repl> nvfetcherConfig = with builtins; fromTOML (readFile ./nvfetcher.toml)
nix-repl> tomlFormat = pkgs.formats.toml {}
nix-repl> nvfetcherToml = tomlFormat.generate "nvfetcher-config" nvfetcherConfig
nix-repl> :bl nvfetcherToml
This derivation produced the following outputs:
./repl-result-out -> /nix/store/cwys5757jblff2grc8cqdlbsgdg4k4md-nvfetcher-config
nix-repl> :q
$ nvfetcher -c repl-result-out
nvfetcher: tomland errors number: 22
tomland decode error: Key src.github is not found
tomland decode error: Key src.github_tag is not found
tomland decode error: Key src.git is not found
tomland decode error: Key src.pypi is not found
tomland decode error: Key src.archpkg is not found
tomland decode error: Key src.aur is not found
tomland decode error: Key src.manual is not found
tomland decode error: Key src.repology is not found
tomland decode error: Key src.webpage is not found
tomland decode error: Key src.regex is not found
tomland decode error: Key src.httpheader is not found
tomland decode error: Key src.regex is not found
tomland decode error: Key src.openvsx is not found
tomland decode error: Key src.vsmarketplace is not found
tomland decode error: Key src.cmd is not found
tomland decode error: Key fetch.github is not found
tomland decode error: Key fetch.pypi is not found
tomland decode error: Key fetch.openvsx is not found
tomland decode error: Key fetch.vsmarketplace is not found
tomland decode error: Key fetch.git is not found
tomland decode error: Key fetch.url is not found
tomland decode error: Key fetch.tarball is not found
CallStack (from HasCallStack):
error, called at app/Main.hs:35:17 in main:Main
Would it be possible to update the internal TOML parser to support this use case?
Thank you for your issue. The generated TOML looks like:
[feeluown-core]
[feeluown-core.fetch]
pypi = "feeluown"
[feeluown-core.src]
pypi = "feeluown"
The parse failed because current config parser doesn't resolve parsed TOML semantically - instead, it assumes that each top-level table represents a package, and keys must be in the form of src.pypi, fetch.pypi,.etc: https://github.com/berberman/nvfetcher/blob/9763ad40d59a044e90726653d9253efaeeb053b2/app/Config/VersionSource.hs#L127
I thought this would be the straightforward way for human, but it's also important to obey the semantic of TOML. Rewriting the config parser requires a bit of work. I will try to work on that.