It’s helpful to have a build ID compiled into the binary that can be included as part of the binary’s outputs. For example, a C++ program that runs FEA simulations might include the latest git tag and git commit hash that it was built from to help identify itself.
Prior to Nix Flakes, we did this by having Meson run git describe --always and saving the output to a file which was included into the compiled binary.
This isn’t possible with Nix Flakes since builds are done in a sandbox where all of the git metadata is gone.
Is there a new suggested way to do pass this information into the binary? This is a useful feature to have and does not affect reproducibility.
If your tree is clean, self.shortRev is also exposed. So no need for substrings.
Additionally, sourceInfo (on all flakes) exposes added “metadata” you might be interested in: