This patch turned out to be much larger than expected, and mostly for tedious reasons. I recommend reviewing one commit at a time, as two of these are very mechanical (changing constraints and adding fields to some data types).
I added support to stackage-curator recently to include hashes of .cabal files for newly generated snapshots. This patch will ensure that, when using Git as a package index and a snapshot with this hash information, we get the same version of the .cabal file as was used when generating the snapshot, avoiding the possibility of Hackage edits from corrupting the snapshot for end users.
I recommend holding off on merging this for a few days so it can be properly tested with upstream Stackage Nightly snapshots that actually have this .cabal hash information.