nmattia / niv

Easy dependency management for Nix projects
https://github.com/nmattia/niv
MIT License
1.55k stars 77 forks source link

Support `sources.json` being JSON5 to allow comments #284

Open hansl opened 3 years ago

yaitskov commented 3 years ago

+1 to have comments

zimbatm commented 3 years ago

This is not possible without changing Nix itself. If you want JSON5 to be added then it will require to extend builtins.fromJSON with that support, or introduce a new builtins.fromJSON5 builtin.

refnil commented 3 years ago

I agree with zimbatm that we should wait for a nix builtins before supporting JSON5. The alternative is to use the "import from derivation", which may not be appropriate in all niv use cases.

I tried implementing the feature by using by catching the fromJSON error in hope of falling back to a implementation of fromJSON using import from derivation. It didn't looks it was possible to catch this fromJSON error. This solution would also need changing nix itself.

zimbatm commented 3 years ago

Actually, a different possibility would be to serialize the file as Nix. It supports JSON-like data structures, and comments.