gunk-dev/the-valley

hosts.nix

source3705a182e12bmain's published tip history
3.9 KiB
1# The hosts the module checks are about: eval-only instantiations of the
2# NixOS module, one per declaration worth holding it to. Evaluating one
3# catches option-surface and cue-export regressions without building or
4# booting anything, and the hook checks read the scripts these render.
5{
6 pkgs,
7 lib,
8 self,
9 system,
10}:
11let
12 # Each check host shares the machine baseline and supplies its own
13 # declaration (and, where the declaration asks for backup, the secret
14 # paths).
15 mkHost =
16 module:
17 lib.nixosSystem {
18 inherit system;
19 modules = [
20 self.nixosModules.default
21 {
22 fileSystems."/" = {
23 device = "/dev/disk/by-label/nixos";
24 fsType = "ext4";
25 };
26 boot.loader.grub.enable = false;
27 system.stateVersion = "25.11";
28 services.valley = {
29 enable = true;
30 authorizedKeys = [
31 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPlaceholderKeyForEvalOnlyCheck0 valley-check"
32 ];
33 };
34 }
35 module
36 ];
37 };
38in
39{
40 # The example declaration enables backup, so this host supplies
41 # the four secret paths (eval-only placeholders).
42 host = mkHost {
43 services.valley = {
44 config = ../../examples/host.cue;
45 backup = {
46 repositoryFile = "/run/agenix/valley-restic-repo";
47 passwordFile = "/run/agenix/valley-restic-password";
48 sshKeyFile = "/run/agenix/valley-git-ssh-key";
49 knownHostsFile = "/var/lib/valley-backup/known_hosts";
50 };
51 };
52 };
53
54 # A declaration with no optional field set at all โ€” no backup, no
55 # protection โ€” must keep evaluating exactly as it did before those
56 # fields existed: zero restic machinery, no hook.
57 noBackupHost = mkHost {
58 services.valley.config = ../../examples/hosts/no-backup.cue;
59 };
60
61 # The example declaration with the secret paths left unset: the
62 # module must refuse with assertions naming the missing options.
63 noSecretsHost = mkHost {
64 services.valley.config = ../../examples/host.cue;
65 };
66
67 # Bus enabled, minimal declaration. The bus-e2e check drives this
68 # host's rendered hooks and stream-init against a real server.
69 busHost = mkHost {
70 services.valley = {
71 config = ../../examples/hosts/bus.cue;
72 bus.enable = true;
73 };
74 };
75
76 # Two mirror URLs the sandbox can serve: git resolves a relative
77 # URL against the pushing repo's directory, so the mirror-e2e
78 # check drives the rendered script with no substitution at all โ€”
79 # one reachable sibling repo, one that does not exist.
80 mirrorHost = mkHost {
81 services.valley.config = ../../examples/hosts/mirrors.cue;
82 };
83
84 # The protection declaration, plus the machine half it needs: keys
85 # bound to the principal names it uses. The baseline key above is
86 # anonymous and stays in the list, so this host also renders the
87 # two forms of key side by side.
88 protectedHost = mkHost {
89 services.valley = {
90 config = ../../examples/hosts/protected.cue;
91 authorizedKeys = [
92 {
93 principal = "integrator";
94 key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPlaceholderKeyForEvalOnlyCheck1 integrator";
95 }
96 {
97 principal = "contributor";
98 key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPlaceholderKeyForEvalOnlyCheck2 contributor";
99 }
100 ];
101 };
102 };
103
104 # The same protection declaration with the controllers switched on. The
105 # integrator serves exactly what that declaration protects, so this host
106 # renders two controllers and no third; the paths are eval-only
107 # placeholders, like the backup host's.
108 integratorHost = mkHost {
109 services.valley = {
110 config = ../../examples/hosts/protected.cue;
111 integrator = {
112 enable = true;
113 signingKeyFile = "/run/agenix/valley-integrator-key";
114 knownSignersFile = "/var/lib/valley-instance/known_signers";
115 instancePolicy = "/var/lib/valley-instance/policy";
116 };
117 };
118 };
119}