gunk-dev/the-valley

identity.nix

source936ef76e084emain's published tip history
1.9 KiB
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, and the registry is read past
7# a replacement ref planted to forge it.
8#
9# The schema's own rejections live with the other schemas, in schema.nix.
10{
11 pkgs,
12 packages,
13 hosts,
14 ...
15}:
16{
17 # The compiler's Go tests, run in the package's checkPhase: the key
18 # hash pinned against the reference vector attest is held to, expiry,
19 # and the renders it must refuse.
20 identity-unit = packages.identity-unwrapped;
21
22 identity-e2e = pkgs.runCommand "valley-identity-e2e" {
23 nativeBuildInputs = [
24 pkgs.git
25 pkgs.openssh
26 packages.identity
27 # attest, so the compiled verifier line is checked against the
28 # implementation that reads it and not only against a fixed vector.
29 packages.attest
30 ];
31 registry = ../../examples/identity/registry;
32 compiled = ../../examples/identity/compiled;
33 expired = ../../examples/identity/expired;
34 # The fail-safe case. Any invalid registry would do; this one fails on a
35 # property of the floor rather than on a typo, so the check also
36 # observes that a floor violation is what stops a compilation.
37 invalid = ../../examples/identity/rejected/external-governs-registry.cue;
38 # A host compiling the registry, whose rendered pre-receive hook reads
39 # the compiled grants. The check follows the hook out of its init
40 # script, so what it drives is what such a host would run.
41 identityInitScript = hosts.identityHost.config.systemd.services.valley-init.script;
42 passAsFile = [ "identityInitScript" ];
43 } (builtins.readFile ./identity-e2e.sh);
44}