This effectively duplicates the behaviour in Guix for serializing derivations,
but this uses the database representation in the Guix Data Service, rather
than the records Guix uses.
Previously, they were nix-base32-string encoded, but the representation in the
derivations is base16, so it doesn't make sense to use a different
representation in the database.
Therefore, add some code that runs before the start of each job to convert the
data in the database. It was easier to do this in Guile with the existing
support for working with these bytevector representations. After some
migration period, the code for converting the old hashes can be removed.
Both in terms of the code fetching the data from the database, as well as the
formatted and detail outputs. This corrects an error in the formatted output
for derivations where inputs would be duplicated.
Create select-build-id-by-build-server-and-derivation-file-name, which just
returns the id, and then a variant that returns more fields for making a page
for each build.
Rather than just counting builds where the derivation matches, select builds
based on the derivation outputs, which accounts for different but equivalent
derivations.
Derivations are effectively equivalent if they produce the same set of
outputs, which is possible because of the equivalence of fixed output
derivations. A fixed output derivation can be different, but equivalent,
because it produces the same fixed output.
To better allow tracking equivalent derivations, primarily to allow working
out what derivations might correspond to a build, store the sets of derivation
outputs, and which derivations they relate to.
The join on derivation_outputs was completely wrong, so fix that.
Also, rather than only selecting outputs where there's a corresponding build,
just eliminate outputs where there is an entry in the nars table, fetched from
the relevant build server.
Also just look at x86_64-linux derivations, because there's no filtering on
relevant derivations for a build server at the moment.
Allow for build status information to be submitted by POST request. This
required some changes to the builds and build_status tables, as for example,
the Cuirass build id may not be available, and the derivation may not be know
yet, so just record the derivation file name.
The intent with these tokens is for them to be provided when build events are
submitted, preventing unauthorised submission of build events.
It should be possible to make the database public, so it shouldn't contain any
secret information. To have secret tokens that aren't in the database, store a
token seed, and combine this with some secret data to compute the secret.