| 1 | # The identity registry compiler, driven end to end. What it renders is |
| 2 | # checkable against something already written down: the known-signers file |
| 3 | # the instance maintains by hand today is exactly what the registry must |
| 4 | # compile to, so the golden case is a byte-for-byte comparison against the |
| 5 | # artifact this compiler exists to replace. The grants it compiles are then |
| 6 | # read by the pre-receive hook a host renders: the approve grant, also |
| 7 | # accepted as request, and restack, whose holder adds a version to another |
| 8 | # principal's ready change and writes its restack report. A registry naming |
| 9 | # the approve grant under either name compiles the same grants, and the |
| 10 | # hook reads a grants file naming either: a holder under either name, or |
| 11 | # both, files a request and updates and deletes another principal's change |
| 12 | # record, and a principal holding neither, including one named approve, |
| 13 | # does none of that. A grant named approve at a boundary of another kind |
| 14 | # compiles to nothing. The registry is read past a replacement ref planted |
| 15 | # to forge it. |
| 16 | # |
| 17 | # The schema's own rejections live with the other schemas, in schema.nix. |
| 18 | { |
| 19 | pkgs, |
| 20 | packages, |
| 21 | hosts, |
| 22 | ... |
| 23 | }: |
| 24 | { |
| 25 | # The compiler's Go tests, run in the package's checkPhase: the key |
| 26 | # hash pinned against the reference vector attest is held to, expiry, |
| 27 | # and the renders it must refuse. |
| 28 | identity-unit = packages.identity-unwrapped; |
| 29 | |
| 30 | identity-e2e = pkgs.runCommand "valley-identity-e2e" { |
| 31 | nativeBuildInputs = [ |
| 32 | pkgs.git |
| 33 | pkgs.openssh |
| 34 | packages.identity |
| 35 | # attest, so the compiled verifier line is checked against the |
| 36 | # implementation that reads it and not only against a fixed vector. |
| 37 | packages.attest |
| 38 | ]; |
| 39 | registry = ../../examples/identity/registry; |
| 40 | compiled = ../../examples/identity/compiled; |
| 41 | expired = ../../examples/identity/expired; |
| 42 | # The fail-safe case. Any invalid registry would do; this one fails on a |
| 43 | # property of the floor rather than on a typo, so the check also |
| 44 | # observes that a floor violation is what stops a compilation. |
| 45 | invalid = ../../examples/identity/rejected/external-governs-registry.cue; |
| 46 | # A host compiling the registry, whose rendered pre-receive hook reads |
| 47 | # the compiled grants. The check follows the hook out of its init |
| 48 | # script, so what it drives is what such a host would run. |
| 49 | identityInitScript = hosts.identityHost.config.systemd.services.valley-init.script; |
| 50 | passAsFile = [ "identityInitScript" ]; |
| 51 | } (builtins.readFile ./identity-e2e.sh); |
| 52 | } |