How to get image tag from dockerTools build{Layered}Image?

I can use dockerTools buildImage or buildLayeredImage to build an image, and then import it to docker (docker load) or send it to a registry. But if I let nix generate the image tag automatically (from inputs I assume), I can’t access it. I’ve seen workarounds that parse the output from docker load (which prints the image name including tag to stdout), but that seems as that, a workaround.

Would it be possible to make the tag available in the return value of buildImage/buildLayeredImage? Eg. something like

let
  image = dockerTools.buildLayeredImage { … }

  tag = image.tag // <- the tag as generated by nix.

Isn’t the tag already available under the imageTag attribute?

$ nix eval nixpkgs#dockerTools.examples.bashNoTagLayered.imageTag
"0k0pyqixv5s32gzsr5pjg3pmgas9kbjf"

Indeed, imageTag is it.

For future, where would one find documentation about what attributes exist on the object that buildLayeredImage returns?

I’m not aware of any such documentation sadly.

While the documentation is infamously lacking, you can use tab completion in the nix repl to explore at least. I also find just reading the nixpkgs source is surprisingly useful, though it’s annoying I have to so frequently.