[fabrica] Layers and the verifiable build: the layers pipeline runs all five test layers on a NixOS runner with KVM, verify-nix rebuilds a tag and compares with its pin, the release publishes the Nix pin (ianitor-nix.json) under the signed SHA256SUMS; scripts for conformance, load and the pin; docs/verify.md
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
untrusted comment: minisign public key ABD87B469ADF4BE4
|
||||
RWTkS9+aRnvYq1si0VvyJFeEJf7oQ3Dsadl0/fI64nuVIaz286PGiyPe
|
||||
@@ -0,0 +1,78 @@
|
||||
# Verifying a release
|
||||
|
||||
Every Ianitor release on Gitea (`vX.Y.Z`) carries `SHA256SUMS` and `SHA256SUMS.minisig`, signed through Custos by
|
||||
the `domi-release` key, and among the files that `SHA256SUMS` lists, `ianitor-nix.json`: the tag's commit and the
|
||||
NAR hash of every Nix output (`.#ianitor`, the two binaries; `.#ianitor-web`, the built UI). Ianitor ships no
|
||||
binary download: you build the tag yourself (or your server does, through the NixOS module) and check that you got
|
||||
exactly the bytes the release vouches for. The build is reproducible: `scripts/nix-pin.sh` builds each output twice
|
||||
from scratch and refuses to pin one whose bytes differ, and the `verify-nix` pipeline rebuilds every tag on the
|
||||
NixOS runner and compares.
|
||||
|
||||
## 1. The signature
|
||||
|
||||
The `domi-release` public key, key id `ABD87B469ADF4BE4` (also in [domi-release.pub](domi-release.pub)):
|
||||
|
||||
```text
|
||||
untrusted comment: minisign public key ABD87B469ADF4BE4
|
||||
RWTkS9+aRnvYq1si0VvyJFeEJf7oQ3Dsadl0/fI64nuVIaz286PGiyPe
|
||||
```
|
||||
|
||||
Take it from a source you trust more than the release page itself (Custos → *Signing keys* → *Copy minisign.pub*,
|
||||
or a clone of this repository you already had). Then, in a folder with the release's files:
|
||||
|
||||
```sh
|
||||
minisign -Vm SHA256SUMS -p domi-release.pub # "Signature and comment signature verified"
|
||||
sha256sum -c --ignore-missing SHA256SUMS # every downloaded file: OK
|
||||
```
|
||||
|
||||
(`nix shell nixpkgs#minisign` if you have no minisign. Custos signs prehashed; minisign 0.10 and later verify it.)
|
||||
|
||||
## 2. The build
|
||||
|
||||
`ianitor-nix.json` names the commit and the hashes:
|
||||
|
||||
```json
|
||||
{ "version": "1.0.0", "commit": "<40 hex>", "system": "x86_64-linux",
|
||||
"outputs": { "ianitor": { "storePath": "/nix/store/…-ianitor-1.0.0", "narHash": "sha256-…" }, … } }
|
||||
```
|
||||
|
||||
Build that commit and compare (Linux with Nix and flakes; nothing from Ianitor's own caches is needed):
|
||||
|
||||
```sh
|
||||
c=$(jq -r .commit ianitor-nix.json)
|
||||
for a in ianitor ianitor-web; do
|
||||
p=$(nix build "git+https://gitea.marek-novak.cz/mnovak/Ianitor.git?rev=$c#$a" --no-link --print-out-paths)
|
||||
got=$(nix path-info --json "$p" | jq -r 'if type == "array" then .[0].narHash else .[].narHash end')
|
||||
want=$(jq -r ".outputs[\"$a\"].narHash" ianitor-nix.json)
|
||||
[ "$got" = "$want" ] && echo "$a: $got matches" || echo "$a: MISMATCH (got $got, release says $want)"
|
||||
done
|
||||
```
|
||||
|
||||
The store path matches too (it depends only on the derivation, so it tells you the inputs were the same); the NAR
|
||||
hash is the content. `nix build --rebuild` builds once more locally and fails if your own two builds differ.
|
||||
|
||||
On a server that uses the NixOS module, the running build is `services.ianitor.package`, normally
|
||||
`ianitor.packages.x86_64-linux.ianitor` from the flake input pinned in the server's `flake.lock`: if that input's
|
||||
`rev` is the release's commit, `nix path-info --json $(readlink -f /run/current-system/sw/bin/ianitor-edge | sed 's#/bin/.*##')`
|
||||
gives the same NAR hash.
|
||||
|
||||
## What this does and does not prove
|
||||
|
||||
- **Proves:** the release's notes, screenshots and pin are the ones Mark approved and Custos signed; the code at the
|
||||
pinned commit builds to exactly the pinned bytes, on any machine with the same nixpkgs (the flake.lock is part of
|
||||
the commit).
|
||||
- **Does not prove:** that the code is good (that is the five test layers' job, ROADMAP §5), nor anything about the
|
||||
Nix binary cache you build with: a substituted dependency is trusted as Nix trusts it. `nix build --rebuild` and
|
||||
`--option substitute false` narrow that, at the cost of building everything.
|
||||
|
||||
## For Mark: making the pin before a tag
|
||||
|
||||
On a Linux machine with Nix (WSL2 Debian works), at the commit to be tagged:
|
||||
|
||||
```sh
|
||||
scripts/nix-pin.sh # builds twice, writes .fabrica/nix/pin.json
|
||||
git add .fabrica/nix/pin.json && git commit -m "[repo] Release: the Nix pin of X.Y.Z"
|
||||
```
|
||||
|
||||
The pin lies outside every package's source, so the commit does not change what it pins. The `release` pipeline's
|
||||
`pin` step refuses a pin of another version, so a forgotten pin stops the release before anything is published.
|
||||
Reference in New Issue
Block a user