Nix github or Tarball meta data - rev - and json file dump

I would like to get the meta data about nixpkgs unstable

something like

builtins.fetchGit { url = ""; }
{ ... rev= ... }  (date= ..  would also be nice)

after retrieving the set of meta data I would like to dump that as json file.

How to do that is an short and efficient way in nix