niv icon indicating copy to clipboard operation
niv copied to clipboard

Support `sources.json` being JSON5 to allow comments

Open hansl opened this issue 5 years ago • 4 comments

hansl avatar Sep 28 '20 16:09 hansl

+1 to have comments

yaitskov avatar Aug 09 '21 14:08 yaitskov

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.

zimbatm avatar Aug 12 '21 18:08 zimbatm

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.

refnil avatar Aug 14 '21 07:08 refnil

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

zimbatm avatar Aug 14 '21 16:08 zimbatm