gunk-dev/the-valley

host-module.nix

source53bd156eeb1bmain's published tip history
51.3 KiB
1# What the NixOS modules render from a declaration, and what they must refuse.
2# This covers the valley host module, the web publisher module alongside it,
3# and the web receiver module on an edge host.
4# The refusals are eval-time: a host that must not evaluate is caught by a
5# throw here, since there is nothing to build once it has. What a host does
6# render is pinned by module-eval.sh over the rendered scripts.
7#
8# Every host here runs the stand-ins for this flake's programs
9# (nix/checks/hosts.nix). Nothing here runs a program: each assertion is
10# about the units, hooks and scripts the module renders, which name a
11# program's path and the flags it is given. So module-eval changes when the
12# module, a host declaration or this check does, and not when a program
13# does.
14{
15 pkgs,
16 lib,
17 self,
18 stubbedHosts,
19 ...
20}:
21let
22 inherit (stubbedHosts)
23 unprotectedInstanceHost
24 acceptEnvHost
25 matchAcceptEnvHost
26 wildcardAcceptEnvHost
27 quotedAcceptEnvHost
28 tabAcceptEnvHost
29 setEnvHost
30 permitUserEnvironmentHost
31 conflictingKeysHost
32 host
33 noBackupHost
34 noSecretsHost
35 protectedHost
36 busHost
37 mirrorHost
38 integratorHost
39 integratorSelfHost
40 restrictedHost
41 spacedSignerProjectsHost
42 unicodeSpacedSignerProjectsHost
43 identityHost
44 workerHost
45 buildSliceHost
46 noSliceWorkerHost
47 unrestrictedWorkerHost
48 widerWorkerHost
49 integratorNamedWorkerHost
50 restackerHost
51 unservedRestackerHost
52 keylessRestackerHost
53 ;
54
55 # The web publisher's module (nix/web-publisher.nix) beside the host
56 # module, over integratorHost: its instance repository is the one the
57 # controllers read the floor from. The host also has a backup key the
58 # publisher must not read. The publisher is a stand-in, as the host's
59 # programs are. webPublisherOffHost imports the module and leaves it off.
60 webPublisherStub = pkgs.writeShellScriptBin "valley-web-publish" ''
61 echo "valley-web-publish: a stand-in the module checks render hosts over, which runs nothing" >&2
62 exit 1
63 '';
64 webPublisherOffHost = stubbedHosts.integratorHost.extendModules {
65 modules = [
66 self.nixosModules.web-publisher
67 { services.valley.webPublisher.package = webPublisherStub; }
68 ];
69 };
70 webPublisherHost = webPublisherOffHost.extendModules {
71 modules = [
72 {
73 networking.hostName = "valley-host";
74 services.valley.backup.sshKeyFile = "/run/agenix/valley-git-ssh-key";
75 services.valley.webPublisher = {
76 enable = true;
77 destination = "example.org";
78 receiver = "https://example.org";
79 receiverTokenFile = "/run/keys/valley-web-receiver-token";
80 allowedAddresses = [
81 "192.0.2.10"
82 "2001:db8::10"
83 ];
84 principals = {
85 operator = "operator";
86 alice = "agent";
87 };
88 };
89 }
90 ];
91 };
92 # The publisher reading the registry at a ref the instance repository's
93 # protection does not cover.
94 unprotectedRegistryWebPublisherHost = webPublisherHost.extendModules {
95 modules = [ { services.valley.identity.ref = "refs/heads/registry"; } ];
96 };
97 # The publisher reading the registry at a short ref name, which git would
98 # resolve by trying other names in turn.
99 shortRegistryRefWebPublisherHost = webPublisherHost.extendModules {
100 modules = [ { services.valley.identity.ref = "registry"; } ];
101 };
102 # The publisher with no instance repository to discover the projects and
103 # the signers through.
104 noInstanceWebPublisherHost = webPublisherHost.extendModules {
105 modules = [
106 {
107 services.valley.integrator = {
108 instanceProject = lib.mkForce null;
109 instancePolicy = "/var/lib/valley-instance/policy/instance";
110 };
111 }
112 ];
113 };
114
115 # The web receiver module (nix/web-receiver.nix) on a standalone edge
116 # host, evaluated with stand-in binaries. webReceiverOffHost imports the
117 # module while leaving it disabled.
118 edgeStub =
119 name:
120 pkgs.writeShellScriptBin name ''
121 echo "${name}: a stand-in the module checks render hosts over, which runs nothing" >&2
122 exit 1
123 '';
124 webReceiverOffHost = lib.nixosSystem {
125 inherit pkgs;
126 modules = [
127 self.nixosModules.web-receiver
128 {
129 fileSystems."/" = {
130 device = "/dev/disk/by-label/nixos";
131 fsType = "ext4";
132 };
133 boot.loader.grub.enable = false;
134 system.stateVersion = "25.11";
135 services.valley.webReceiver = {
136 receiverPackage = edgeStub "valley-web-receive";
137 webPackage = edgeStub "valley-web";
138 };
139 }
140 ];
141 };
142 webReceiverHost = webReceiverOffHost.extendModules {
143 modules = [
144 {
145 services.valley.webReceiver = {
146 enable = true;
147 instance = "valley-host";
148 destination = "example.org";
149 verifiers = [ "valley-host/web-export+1a2b3c4d+AQ" ];
150 tokenFile = "/run/keys/valley-web-receiver-token";
151 listen = "192.0.2.10:8081";
152 webListen = "127.0.0.1:8080";
153 };
154 }
155 ];
156 };
157 # The receiver with its token in the Nix store, and with no verifier.
158 storeTokenWebReceiverHost = webReceiverHost.extendModules {
159 modules = [
160 { services.valley.webReceiver.tokenFile = lib.mkForce "${pkgs.writeText "token" "x"}"; }
161 ];
162 };
163 noVerifierWebReceiverHost = webReceiverHost.extendModules {
164 modules = [ { services.valley.webReceiver.verifiers = lib.mkForce [ ]; } ];
165 };
166 # The publisher allowed to connect to no address.
167 noAddressWebPublisherHost = webPublisherHost.extendModules {
168 modules = [ { services.valley.webPublisher.allowedAddresses = lib.mkForce [ ]; } ];
169 };
170 # The publisher allowed the canary its unit's check must be denied.
171 canaryWebPublisherHost = webPublisherHost.extendModules {
172 modules = [ { services.valley.webPublisher.allowedAddresses = [ "198.51.100.0/24" ]; } ];
173 };
174 # The publisher with its token in the Nix store.
175 storeTokenWebPublisherHost = webPublisherHost.extendModules {
176 modules = [
177 { services.valley.webPublisher.receiverTokenFile = lib.mkForce "${pkgs.writeText "token" "x"}"; }
178 ];
179 };
180
181 failedAssertions = builtins.filter (a: !a.assertion) (
182 host.config.assertions
183 ++ noBackupHost.config.assertions
184 ++ busHost.config.assertions
185 ++ mirrorHost.config.assertions
186 ++ protectedHost.config.assertions
187 ++ integratorHost.config.assertions
188 ++ integratorSelfHost.config.assertions
189 ++ restrictedHost.config.assertions
190 ++ identityHost.config.assertions
191 ++ workerHost.config.assertions
192 ++ restackerHost.config.assertions
193 ++ buildSliceHost.config.assertions
194 ++ webPublisherHost.config.assertions
195 ++ webPublisherOffHost.config.assertions
196 ++ webReceiverHost.config.assertions
197 ++ webReceiverOffHost.config.assertions
198 );
199
200 missingSecretAssertions = builtins.filter (a: !a.assertion) noSecretsHost.config.assertions;
201
202 # The hosts the module must refuse, each with the words its refusal must
203 # say. An assertion that stopped firing would leave the push policy
204 # quietly wrong, so each is held to naming what is wrong.
205 refusedHosts = [
206 {
207 host = unprotectedInstanceHost;
208 says = "whose refs/heads/main is not protected";
209 why = "an instance repository without protection would let any key that can push rewrite the floor and the registry";
210 }
211 {
212 host = acceptEnvHost;
213 says = "AcceptEnv";
214 why = "sshd accepting the principal variable from the client would let any key name any principal";
215 }
216 {
217 host = matchAcceptEnvHost;
218 says = "GIT_CONFIG_*";
219 why = "sshd accepting GIT_ variables in the git user's Match block, in whatever case the keyword is written, would let a client set git's configuration";
220 }
221 {
222 host = wildcardAcceptEnvHost;
223 says = "G?T_*";
224 why = "a wildcard that admits GIT_ variables admits them however it is spelled";
225 }
226 {
227 host = quotedAcceptEnvHost;
228 says = "holds a quote or a backslash";
229 why = "a quoted name is one sshd unquotes and admits, so a check that read it differently would pass it";
230 }
231 {
232 host = tabAcceptEnvHost;
233 says = "VALLEY_PRINCIPAL from the client";
234 why = "a name after a tab is a name sshd admits";
235 }
236 {
237 host = setEnvHost;
238 says = "SetEnv";
239 why = "sshd setting the principal itself would make every key push as it";
240 }
241 {
242 host = permitUserEnvironmentHost;
243 says = "PermitUserEnvironment";
244 why = "a PermitUserEnvironment wider than the principal variable would let a key's entry or ~/.ssh/environment set what the push policy does not expect";
245 }
246 {
247 host = spacedSignerProjectsHost;
248 says = "services.valley.integrator.signerProjects holds";
249 why = "a project with a space in it would be read back as two projects the declaration never listed";
250 }
251 {
252 host = unicodeSpacedSignerProjectsHost;
253 says = "services.valley.integrator.signerProjects holds";
254 why = "a project holding a no-break space would be read back by the integrator as two projects, or refused at start";
255 }
256 {
257 host = noSliceWorkerHost;
258 says = "services.valley.worker.enable needs services.valley.buildSlice.enable";
259 why = "a worker on a host without the build slice would build uncapped, and capping every build of the daemon is the host's decision, not the worker's";
260 }
261 {
262 host = unrestrictedWorkerHost;
263 says = "must restrict worker.valley.invalid/attestations, the worker's signer, to exactly the worker's projects";
264 why = "a worker whose signer no project list restricts would have its evidence counted in every project by every controller that holds its key";
265 }
266 {
267 host = widerWorkerHost;
268 says = "must restrict worker.valley.invalid/attestations, the worker's signer, to exactly the worker's projects";
269 why = "a worker trusted in a project it does not build would be trusted where it does no work";
270 }
271 {
272 host = integratorNamedWorkerHost;
273 says = "services.valley.worker.signerName must differ from integrator";
274 why = "a worker signing under the controllers' name would make every controller refuse to start";
275 }
276 {
277 host = unservedRestackerHost;
278 says = "services.valley.restacker.projects must name at least one project, and only projects this host serves, and it names nowhere";
279 why = "a controller for a project the host does not serve would fail every pass";
280 }
281 {
282 host = keylessRestackerHost;
283 says = "services.valley.restacker.sshKeyFile must be set";
284 why = "a restacker with no key cannot reach the repositories it serves, except as a user that could write them on disk";
285 }
286 {
287 host = conflictingKeysHost;
288 says = "more than one principal tag";
289 why = "a key declared under two tags would push as whichever entry sshd reads first";
290 }
291 {
292 host = unprotectedRegistryWebPublisherHost;
293 says = "whose refs/heads/registry is not protected";
294 why = "a publisher reading the registry at an unprotected ref would let any key that can push there grant anyone read";
295 }
296 {
297 host = shortRegistryRefWebPublisherHost;
298 says = "services.valley.identity.ref is registry, which is not a full ref name";
299 why = "git resolves a ref that is not a full name by trying several refs in turn, and a pusher can make one of them";
300 }
301 {
302 host = storeTokenWebPublisherHost;
303 says = "services.valley.webPublisher.receiverTokenFile is in the Nix store";
304 why = "the publisher's receiver token is in the Nix store";
305 }
306 {
307 host = noAddressWebPublisherHost;
308 says = "services.valley.webPublisher.allowedAddresses is empty: list the receiver's IP addresses";
309 why = "a publisher with no allowed address would either reach nothing or, allowed everything, reach any host";
310 }
311 {
312 host = canaryWebPublisherHost;
313 says = "services.valley.webPublisher.allowedAddresses covers 198.51.100.1";
314 why = "the check before each pass could not prove the filter in force if the filter allowed its canary";
315 }
316 {
317 host = storeTokenWebReceiverHost;
318 says = "services.valley.webReceiver.tokenFile is in the Nix store";
319 why = "the receiver's token is in the Nix store";
320 }
321 {
322 host = noVerifierWebReceiverHost;
323 says = "services.valley.webReceiver.verifiers names no verifier line";
324 why = "the receiver pins no verifier";
325 }
326 {
327 host = noInstanceWebPublisherHost;
328 says = "services.valley.webPublisher needs services.valley.integrator.instanceProject";
329 why = "a publisher with no instance repository has no publication to discover the projects and their signers through";
330 }
331 ];
332
333 unrefusedHosts = builtins.filter (
334 r: !(lib.any (a: !a.assertion && lib.hasInfix r.says a.message) r.host.config.assertions)
335 ) refusedHosts;
336
337 protectedKeyLines = protectedHost.config.users.users.git.openssh.authorizedKeys.keys;
338
339 resticRenderedWithoutDeclaration =
340 noBackupHost.config.systemd.services ? "restic-backups-valley"
341 || noBackupHost.config.systemd.timers ? "restic-backups-valley";
342
343 # The bus defaults off; a host that never asked for one must
344 # render zero bus machinery.
345 busRenderedWithoutEnable =
346 noBackupHost.config.systemd.services ? valley-bus
347 || noBackupHost.config.systemd.services ? valley-bus-init;
348
349 # A declaration with no protection block and no tagged key still gets
350 # the push policy on every project — the policy is the host's, and a
351 # protection block only adds protected refs to it — and nothing of the
352 # principal machinery: no tag on a key, no sshd change.
353 protectionRenderedWithoutDeclaration =
354 noBackupHost.config.services.openssh.settings ? PermitUserEnvironment
355 || lib.any (lib.hasInfix "environment=") (
356 noBackupHost.config.users.users.git.openssh.authorizedKeys.keys
357 );
358
359 policyMissingWithoutDeclaration =
360 !(lib.hasInfix "valley-protect-the-valley" noBackupHost.config.systemd.services.valley-init.script);
361
362 # The integrator's units. What a controller *does* is not checked here
363 # and no VM is booted: that is integrator-e2e's job (the real binaries
364 # over real repositories) and, past it, live exercise on a host. These
365 # assertions cover the wiring — that a controller is rendered for what
366 # the declaration protects and for nothing else, under an identity that
367 # is not the git user's, pointed at the key and the signers the consumer
368 # supplied.
369 #
370 # There is a seam between those two halves that neither reaches, and in a
371 # single day it produced five deployment failures. Every assertion below is
372 # an eval of the unit's text; integrator-e2e runs the binaries with no unit
373 # around them at all. What sits between is the unit's sandbox and identity
374 # meeting the filesystem the binaries actually use at runtime:
375 #
376 # - git refusing a repository the service does not own (bd-500adf7)
377 # - a push authenticating as the operator rather than as the run
378 # (bd-353c59d)
379 # - no writable temporary directory, so no worktree could be made
380 # - the worktree metadata root, created by whichever service reached it
381 # first and then unchmodable by the other, which failed valley-init and
382 # took every valley unit down with it
383 # - the state directory not writable under ProtectSystem=strict unless
384 # the unit names it, which the previous fix had made the scratch root
385 #
386 # Each was found by a host, minutes of a live service after a deploy that
387 # every check here passed. They compose: the third's fix set up the fourth,
388 # and the fourth's fix set up the fifth. That is the argument. A seam whose
389 # failures feed each other is not one to pin an assertion at a time, and
390 # each assertion here that marks a piece of it — the git ownership
391 # exception, TMPDIR, the worktrees root, ReadWritePaths — marks a place a
392 # smoke boot would have spoken first.
393 #
394 # A nixosTest that boots one host, starts the units and reconciles one
395 # change end to end is the next check this module needs. Nothing else
396 # closes the seam, and five incidents is enough evidence of what it costs
397 # to leave open. Not built here.
398 #
399 # Protection and integration are separable declarations: protectedHost
400 # declares the same protected projects with the service off, and must
401 # evaluate to no controller at all.
402 integratorRenderedWithoutEnable =
403 protectedHost.config.systemd.services ? "valley-integrator@"
404 || protectedHost.config.systemd.targets ? valley-integrators
405 || lib.hasInfix "sharedRepository" protectedHost.config.systemd.services.valley-init.script;
406
407 # One target pulls in each controller, and another the path unit that
408 # publishes each project's queued moves, landings included.
409 integratorWants = integratorHost.config.systemd.targets.valley-integrators.wants;
410 controllers = lib.filter (lib.hasPrefix "valley-integrator@") integratorWants;
411 publishers = integratorHost.config.systemd.targets.valley-publish.wants;
412
413 integratorUser = integratorHost.config.systemd.services."valley-integrator@".serviceConfig.User;
414
415 # The controller is not the repositories' owner, which is the whole point
416 # of running it as itself — so git needs an ownership exception, and
417 # where that exception lives is load-bearing. GIT_CONFIG_* is command
418 # scope, the only scope besides system and global that safe.directory is
419 # read from, and the unit's environment is inherited by every git the
420 # controller drives. It names one repository: a wildcard here would hand
421 # a compromised controller every repository on the host.
422 integratorGitEnv = integratorHost.config.systemd.services."valley-integrator@".environment;
423
424 # The count is what git reads; an entry past it is an entry git ignores,
425 # silently. So it is checked against the entries actually rendered rather
426 # than against a number written here, which would have to be edited every
427 # time a grant is added and would go on passing if it were not.
428 integratorSafeDirectory =
429 integratorGitEnv.GIT_CONFIG_KEY_0 or null != "safe.directory"
430 || integratorGitEnv.GIT_CONFIG_VALUE_0 or null != "/srv/git/%i.git"
431 || integratorGitEnv.GIT_CONFIG_COUNT or null
432 != toString (
433 lib.length (lib.filter (lib.hasPrefix "GIT_CONFIG_KEY_") (lib.attrNames integratorGitEnv))
434 );
435
436 integratorService = integratorHost.config.systemd.services."valley-integrator@".serviceConfig;
437
438 # Scratch goes under the state directory, because the sandbox leaves no
439 # writable temporary directory and a verdict needs a checkout on disk. Two
440 # halves, and each was a live failure on its own. TMPDIR naming a path
441 # outside the state directory is the first; the state directory not being
442 # named in ReadWritePaths is the second, which failed even though
443 # ProtectSystem=strict is documented to leave a declared state directory
444 # writable. Everything the unit may write is enumerated, so what a reader
445 # of the unit sees is the whole of it.
446 # The floor is read from the instance repository's integrated tip
447 # (dcr-f41f718, dcr-b87f6e8), so a controller is told which repository
448 # carries it and reads it there. Three things have to be true of that, and
449 # each was a way for it to be silently wrong.
450 #
451 # The controller has to be told at all — the failure this replaced was a
452 # binary looking for a materialized directory nothing populated.
453 #
454 # It has to work when the repository carrying the floor is not the one the
455 # controller serves, which is the ordinary case: on integratorHost every
456 # controller serves a protected project and reads the floor out of
457 # "open", which no controller serves. git refuses a repository the caller
458 # does not own, so that read needs its own safe.directory entry, named and
459 # not wildcarded — the same failure as the served repository's, one
460 # repository over.
461 #
462 # And it has to keep working when the two coincide, which is what an
463 # instance's own host looks like: integratorSelfHost's controller for
464 # "guarded" reads the floor from "guarded".
465 integratorFloor =
466 let
467 command = integratorHost.config.systemd.services."valley-integrator@".serviceConfig.ExecStart;
468 selfCommand = integratorSelfHost.config.systemd.services."valley-integrator@".serviceConfig.ExecStart;
469 env = integratorHost.config.systemd.services."valley-integrator@".environment;
470 in
471 !(lib.hasInfix "--instance-repo /srv/git/sealed.git" command)
472 || !(lib.hasInfix "--instance-repo /srv/git/guarded.git" selfCommand)
473 || env.GIT_CONFIG_COUNT or null != "2"
474 || env.GIT_CONFIG_KEY_1 or null != "safe.directory"
475 || env.GIT_CONFIG_VALUE_1 or null != "/srv/git/sealed.git";
476
477 integratorScratch =
478 integratorGitEnv.TMPDIR or null != "/var/lib/${integratorService.StateDirectory}"
479 || !(builtins.elem "/var/lib/${integratorService.StateDirectory}" integratorService.ReadWritePaths);
480
481 # The registry compiler. It is off by default and must stay inert: a
482 # consumer that has not asked for it renders the system it always did.
483 # integratorHost is the strongest witness available — the integrator on,
484 # the signers file supplied by hand, and every option of the identity
485 # block left alone.
486 identityRenderedWithoutEnable =
487 integratorHost.config.systemd.services ? valley-identity
488 || integratorHost.config.systemd.timers ? valley-identity
489 || integratorHost.config.services.openssh.settings ? PermitUserEnvironment
490 || lib.any (lib.hasInfix "valley-identity") integratorHost.config.services.openssh.authorizedKeysFiles
491 || lib.hasInfix "valley-identity" integratorHost.config.services.openssh.extraConfig
492 || lib.hasInfix "valley-identity" (
493 integratorHost.config.systemd.services."valley-integrator@".serviceConfig.ExecStart
494 )
495 || lib.hasInfix "--name " (
496 integratorHost.config.systemd.services."valley-integrator@".serviceConfig.ExecStart
497 );
498
499 identityService = identityHost.config.systemd.services.valley-identity.serviceConfig;
500
501 identityStateDir = "/var/lib/${identityService.StateDirectory or ""}";
502
503 # What the compiled artifacts have to be true of, and each was a way for
504 # the machinery to be quietly wrong.
505 #
506 # The compiler writes into its state directory and nowhere else, so that
507 # directory has to be the one path the unit may write.
508 #
509 # sshd walks every directory above an authorized-keys file and refuses a
510 # group- or world-writable one, so the state directory is 0755 rather than
511 # the 0700 a service's state usually takes — and the unit runs as the git
512 # user, because sshd equally refuses a file owned by anyone but root or
513 # the account it authorizes.
514 #
515 # The compiled file is added to what sshd reads for the git user rather
516 # than replacing it, and for the git user alone: the user's Match block
517 # names the declared keys and the compiled ones, and nothing else — no
518 # ~/.ssh/authorized_keys, no AuthorizedKeysCommand — so every key the git
519 # user accepts carries a tag this module or the compiler wrote. The
520 # compiler is handed the declared keys, so it can refuse a registry key
521 # declared under another tag.
522 identityCompiler =
523 identityService.User or null != identityHost.config.services.valley.user
524 || identityService.StateDirectoryMode or null != "0755"
525 || identityService.ReadWritePaths or [ ] != [ identityStateDir ]
526 || !(lib.hasInfix "--repo /srv/git/sealed.git" identityService.ExecStart)
527 || !(lib.hasInfix "--known-signers ${identityStateDir}/known-signers" identityService.ExecStart)
528 || !(lib.hasInfix "--authorized-keys ${identityStateDir}/authorized_keys.git" identityService.ExecStart)
529 || !(lib.hasInfix "--grants ${identityStateDir}/grants" identityService.ExecStart)
530 || !(lib.hasInfix "-valley-declared-keys" identityService.ExecStart)
531 || !(lib.hasInfix "AuthorizedKeysFile /etc/ssh/authorized_keys.d/%u ${identityStateDir}/authorized_keys.git\n" identityHost.config.services.openssh.extraConfig)
532 || !(lib.hasInfix "AuthorizedKeysCommand none" identityHost.config.services.openssh.extraConfig);
533
534 # A controller under a compiled registry reads the compiled signers file
535 # and signs under the name the registry publishes its key under. The key
536 # hash binds name to key, so a controller signing under the host's default
537 # name while the registry publishes it as "integrator" would produce notes
538 # no verifier can find a key for.
539 identityIntegrator =
540 let
541 command = identityHost.config.systemd.services."valley-integrator@".serviceConfig.ExecStart;
542 in
543 !(lib.hasInfix "--known-signers ${identityStateDir}/known-signers" command)
544 || !(lib.hasInfix "--name integrator" command)
545 || !(builtins.elem "valley-identity.service"
546 identityHost.config.systemd.services."valley-integrator@".after
547 );
548
549 # The signers publication. A host whose integrator runs and which serves
550 # the instance repository publishes there what a client verifies its
551 # transfer statements with. What it publishes has to be what the
552 # controllers use: the same signers file and the same --name, or none on
553 # either, in which case both take the binary's default. The publisher
554 # writes as the git user, which owns the instance repository, may write
555 # that repository and nothing else, runs after the compilation when there
556 # is one, and runs again whenever the signers file changes. The signer
557 # projects file is the controllers' too, or neither has one.
558 flagValue =
559 flag: command:
560 let
561 m = builtins.match ".*--${flag} ([^ ]+).*" command;
562 in
563 if m == null then null else lib.head m;
564
565 signersPublisher =
566 host: repo:
567 let
568 unit = host.config.systemd.services.valley-signers;
569 publish = unit.serviceConfig.ExecStart;
570 controller = host.config.systemd.services."valley-integrator@".serviceConfig.ExecStart;
571 in
572 !(lib.hasInfix "/bin/integrator publish-signers " publish)
573 || flagValue "instance-repo" publish != repo
574 || flagValue "known-signers" publish != flagValue "known-signers" controller
575 || flagValue "name" publish != flagValue "name" controller
576 || flagValue "signer-projects" publish != flagValue "signer-projects" controller
577 || unit.serviceConfig.User or null != "git"
578 || unit.serviceConfig.ReadWritePaths or [ ] != [ repo ]
579 || !(builtins.elem "valley-init.service" unit.after)
580 || !(builtins.elem "multi-user.target" unit.wantedBy)
581 || host.config.systemd.paths.valley-signers.pathConfig.PathChanged or null
582 != flagValue "known-signers" controller
583 || !(builtins.elem "multi-user.target" host.config.systemd.paths.valley-signers.wantedBy);
584
585 signersRenderedWithoutIntegrator =
586 protectedHost.config.systemd.services ? valley-signers
587 || protectedHost.config.systemd.paths ? valley-signers;
588
589 signersUnpublished =
590 signersPublisher integratorHost "/srv/git/sealed.git"
591 || signersPublisher restrictedHost "/srv/git/sealed.git"
592 || signersPublisher integratorSelfHost "/srv/git/guarded.git"
593 || signersPublisher identityHost "/srv/git/sealed.git"
594 || flagValue "name" identityHost.config.systemd.services.valley-signers.serviceConfig.ExecStart
595 != "integrator"
596 || !(builtins.elem "valley-identity.service" identityHost.config.systemd.services.valley-signers.after);
597
598 # A host that restricts no signer gives its controllers no signer
599 # projects file, and one that restricts some gives them one.
600 signerProjectsMisrendered =
601 flagValue "signer-projects" integratorHost.config.systemd.services."valley-integrator@".serviceConfig.ExecStart
602 != null
603 || flagValue "signer-projects" restrictedHost.config.systemd.services."valley-integrator@".serviceConfig.ExecStart
604 == null;
605
606 # The declared keys stay authorized beside the compiled ones. A compiled
607 # file that replaced them would make a bad compilation — or a first boot
608 # before the first one — a locked-out git user, which is the one failure
609 # this machinery must never have.
610 identityKeepsDeclaredKeys =
611 identityHost.config.users.users.git.openssh.authorizedKeys.keys == [ ];
612
613 # The check worker and the build slice. Both are off by default, and a
614 # host that never asked for them renders none of either: no unit, no
615 # account, no slice, and a nix daemon where NixOS puts it. integratorHost
616 # is the strongest witness, with the integrator the worker would need
617 # already on.
618 workerRenderedWithoutEnable =
619 integratorHost.config.systemd.services ? valley-worker
620 || integratorHost.config.systemd.timers ? valley-worker
621 || integratorHost.config.systemd.slices ? valley-builds
622 || integratorHost.config.users.users ? valley-worker
623 || integratorHost.config.systemd.services.nix-daemon.serviceConfig ? Slice;
624
625 # The build slice is a host decision of its own. On, it puts the daemon
626 # in the slice at the caps the host names, with no swap, and nothing of
627 # the worker.
628 buildSliceMisrendered =
629 let
630 slice = buildSliceHost.config.systemd.slices.valley-builds.sliceConfig or { };
631 in
632 buildSliceHost.config.systemd.services.nix-daemon.serviceConfig.Slice or null
633 != "valley-builds.slice"
634 || slice.CPUQuota or null != "200%"
635 || slice.MemoryMax or null != "4G"
636 || slice.MemorySwapMax or null != "0"
637 || buildSliceHost.config.systemd.services ? valley-worker
638 || buildSliceHost.config.users.users ? valley-worker;
639
640 # What the VM check runs, held at the operator's values. worker-e2e
641 # boots the worker and lowers the memory cap at runtime to make a build
642 # run past it, so the values themselves are held here. The caps are on
643 # a slice that holds the worker and the nix daemon both, since a build
644 # runs in the daemon's cgroup and never in the worker's; the slice and
645 # the daemon set no device policy, so a NixOS test still gets /dev/kvm.
646 # The worker runs on one CPU, so attest, which runs one nix build per CPU
647 # it may run on, runs one at a time, and each nix build builds one
648 # derivation at a time with 4 cores. The account is not in the git
649 # group, so the repositories on disk are not the worker's to read or
650 # write, and it reaches them only through this host's sshd, checking the
651 # host's key. Its timer starts the first pass five minutes after the
652 # timer starts, not after boot, and each later pass one minute after the
653 # last one ended.
654 workerMisrendered =
655 let
656 unit = workerHost.config.systemd.services.valley-worker;
657 service = unit.serviceConfig;
658 daemon = workerHost.config.systemd.services.nix-daemon.serviceConfig;
659 slice = workerHost.config.systemd.slices.valley-builds.sliceConfig;
660 account = workerHost.config.users.users.valley-worker;
661 timer = workerHost.config.systemd.timers.valley-worker;
662 devicePolicy = c: c ? DevicePolicy || c ? DeviceAllow || c ? PrivateDevices;
663 in
664 service.User or null != "valley-worker"
665 || account.group != "valley-worker"
666 || account.extraGroups != [ ]
667 || service.Type or null != "oneshot"
668 || service.Slice or null != "valley-builds.slice"
669 || daemon.Slice or null != "valley-builds.slice"
670 || slice.CPUQuota or null != "400%"
671 || slice.MemoryMax or null != "8G"
672 || slice.MemorySwapMax or null != "0"
673 || devicePolicy slice
674 || devicePolicy daemon
675 || service.CPUAffinity or null != "0"
676 || !(lib.hasInfix "max-jobs = 1\n" unit.environment.NIX_CONFIG)
677 || !(lib.hasInfix "cores = 4\n" unit.environment.NIX_CONFIG)
678 || !(lib.hasInfix "builders =\n" unit.environment.NIX_CONFIG)
679 || !(lib.hasInfix "-o StrictHostKeyChecking=yes -o HostKeyAlias=localhost" unit.environment.GIT_SSH_COMMAND)
680 || service.ReadWritePaths or [ ] != [
681 "/var/lib/valley-worker"
682 "/nix/var/nix/daemon-socket"
683 ]
684 || !(lib.hasInfix "exec valley-worker --repo guarded --repo sealed --key \"$key\" --name worker.valley.invalid/attestations --state \"$state\"" unit.script)
685 || !(lib.hasInfix "git -C \"$origin\" remote add origin git@localhost:sealed.git\n" unit.script)
686 || timer.timerConfig.OnActiveSec or null != "5m"
687 || timer.timerConfig ? OnBootSec
688 || timer.timerConfig.OnUnitInactiveSec or null != "1m"
689 || !(builtins.elem "timers.target" timer.wantedBy);
690
691 # The restacker. When disabled, it renders no units or user account on
692 # integratorHost. When enabled, each configured project gets a
693 # valley-restacker@<project>.service running valley-restacker run as the
694 # valley-restacker user in its own group, with no access to the bare
695 # repositories on disk. It connects through localhost sshd as its
696 # principal using the key passed via LoadCredential, verifies the host's
697 # own SSH key, has its 0700 state directory as its only persistent
698 # writable path (its private temporary directories are writable too),
699 # and reads the floor from the instance repository over the same SSH
700 # connection.
701 restackerRenderedWithoutEnable =
702 integratorHost.config.systemd.services ? "valley-restacker@"
703 || integratorHost.config.systemd.targets ? valley-restackers
704 || integratorHost.config.users.users ? valley-restacker;
705
706 restackerMisrendered =
707 let
708 unit = restackerHost.config.systemd.services."valley-restacker@";
709 service = unit.serviceConfig;
710 account = restackerHost.config.users.users.valley-restacker;
711 target = restackerHost.config.systemd.targets.valley-restackers;
712 command = service.ExecStart;
713 in
714 service.User or null != "valley-restacker"
715 || service.Group or null != "valley-restacker"
716 || account.group != "valley-restacker"
717 || account.extraGroups != [ ]
718 || service.LoadCredential or [ ] != [ "key:/run/agenix/valley-restacker-key" ]
719 || service.StateDirectory or null != "valley-restacker/%i"
720 || service.StateDirectoryMode or null != "0700"
721 || service.ProtectSystem or null != "strict"
722 || service ? ReadWritePaths
723 || !(lib.hasInfix " -i %d/key " unit.environment.GIT_SSH_COMMAND)
724 || !(lib.hasInfix "-o StrictHostKeyChecking=yes -o HostKeyAlias=localhost" unit.environment.GIT_SSH_COMMAND)
725 || !(lib.hasInfix "-o UserKnownHostsFile=%S/valley-restacker/%i/known_hosts -o GlobalKnownHostsFile=/dev/null" unit.environment.GIT_SSH_COMMAND)
726 || !(lib.hasInfix "/bin/valley-restacker run --repo git@localhost:%i.git --state %S/valley-restacker/%i --principal valley-restacker --interval 15s " command)
727 || !(lib.hasInfix " --instance-repo git@localhost:sealed.git" command)
728 || target.wants != [ "valley-restacker@guarded.service" ]
729 || !(builtins.elem "multi-user.target" target.wantedBy);
730
731 # The web publisher (nix/web-publisher.nix). Off, it renders nothing.
732 # On, one pass is a oneshot on a five-minute timer whose first pass waits
733 # five minutes after the timer starts, and which no switch starts or
734 # restarts. It runs as a dynamic user in the git group, with an empty
735 # safe.directory entry that resets the system's and the user's, then an
736 # exact entry for each repository the host serves and no wildcard, the
737 # repositories read-only, nothing writable but its state and cache, and
738 # the mirror, backup and signing keys out of reach. It may connect to the
739 # addresses it is allowed and to no other, and checks before each pass that
740 # this filter is in force. Its Go lookups use the C library. Its memory is
741 # capped with no swap. It reads the instance repository the controllers
742 # read, names the host as the instance, and is given the receiver, the
743 # destination, the display mapping and the bounds on its bundles and its
744 # storage.
745 webPublisherRenderedWithoutEnable =
746 webPublisherOffHost.config.systemd.services ? valley-web-publish
747 || webPublisherOffHost.config.systemd.timers ? valley-web-publish;
748
749 webPublisherMisrendered =
750 let
751 unit = webPublisherHost.config.systemd.services.valley-web-publish;
752 service = unit.serviceConfig;
753 env = unit.environment;
754 timer = webPublisherHost.config.systemd.timers.valley-web-publish;
755 repos = [
756 "/srv/git/guarded.git"
757 "/srv/git/open.git"
758 "/srv/git/released.git"
759 "/srv/git/sealed.git"
760 ];
761 entries = lib.genList (i: {
762 key = env."GIT_CONFIG_KEY_${toString i}" or null;
763 value = env."GIT_CONFIG_VALUE_${toString i}" or null;
764 }) (lib.length (lib.filter (lib.hasPrefix "GIT_CONFIG_KEY_") (lib.attrNames env)));
765 command = service.ExecStart;
766 in
767 service.Type or null != "oneshot"
768 || service.DynamicUser or null != true
769 || service ? User
770 || service.SupplementaryGroups or [ ] != [ "git" ]
771 || env.GIT_CONFIG_COUNT or null != toString (lib.length repos + 1)
772 || entries != map (r: {
773 key = "safe.directory";
774 value = r;
775 }) ([ "" ] ++ repos)
776 || lib.any (e: lib.hasInfix "*" e.value) entries
777 || service.ProtectSystem or null != "strict"
778 || service ? ReadWritePaths
779 || service.ReadOnlyPaths or [ ] != map (r: "-${r}") repos
780 || service.StateDirectory or null != "valley-web-publish"
781 || service.CacheDirectory or null != "valley-web-publish"
782 || env.XDG_CACHE_HOME or null != "/var/cache/valley-web-publish"
783 || !(lib.all (p: builtins.elem p service.InaccessiblePaths) [
784 "-/srv/git/.ssh"
785 "-/run/agenix/valley-integrator-key"
786 "-/run/agenix/valley-git-ssh-key"
787 "-/var/lib/valley-integrator"
788 ])
789 || !(lib.hasInfix "/bin/valley-web-publish --instance-repo /srv/git/sealed.git --instance valley-host --destination example.org --host /nix/store/" command)
790 || !(lib.hasInfix "-valley-config.json --receiver https://example.org --receiver-token %d/receiver-token --principals /nix/store/" command)
791 || service.LoadCredential or [ ] != [ "receiver-token:/run/keys/valley-web-receiver-token" ]
792 || !(lib.hasInfix "-valley-web-principals.json --state /var/lib/valley-web-publish --max-bundles 1G --max-storage 16G --registry-ref refs/heads/main --registry-dir identity" command)
793 || !(lib.hasSuffix "/bin/valley-web-publish-egress-check 198.51.100.1 9" (service.ExecStartPre or ""))
794 || env.GODEBUG or null != "netdns=cgo"
795 || service.IPAddressDeny or null != "any"
796 || service.IPAddressAllow or null != [
797 "192.0.2.10"
798 "2001:db8::10"
799 ]
800 || service.RestrictAddressFamilies or null != [
801 "AF_INET"
802 "AF_INET6"
803 "AF_UNIX"
804 ]
805 || service.MemoryMax or null != "1G"
806 || service.MemorySwapMax or null != "0"
807 || unit.restartIfChanged != false
808 || unit.wantedBy != [ ]
809 || timer.timerConfig.OnActiveSec or null != "5min"
810 || timer.timerConfig.OnUnitInactiveSec or null != "5min"
811 || !(builtins.elem "timers.target" timer.wantedBy);
812
813 # The web receiver module (nix/web-receiver.nix). When disabled, it
814 # renders no units or users. When enabled, it renders separate systemd
815 # units for valley-web-receive and valley-web; both start at boot, restart
816 # on failure, and run independently. The receiver runs as
817 # valley-web-receive in group valley-web, owns the mode-0750 state
818 # directory, and takes the instance, the destination, the pinned verifiers
819 # from the Nix store, the bearer token as a systemd credential from outside
820 # the store, and the body and storage caps. valley-web runs as valley-web
821 # in the same group, orders after the receiver, mounts the state directory
822 # read-only with no persistent writable paths, and takes the state
823 # directory and its listener address. Each unit has its own memory cap and
824 # disables swap.
825 webReceiverRenderedWithoutEnable =
826 webReceiverOffHost.config.systemd.services ? valley-web-receive
827 || webReceiverOffHost.config.systemd.services ? valley-web
828 || webReceiverOffHost.config.users.users ? valley-web-receive;
829
830 webReceiverMisrendered =
831 let
832 cfg = webReceiverHost.config;
833 receive = cfg.systemd.services.valley-web-receive;
834 web = cfg.systemd.services.valley-web;
835 confined =
836 unit:
837 unit.serviceConfig.ProtectSystem or null == "strict"
838 && unit.serviceConfig.NoNewPrivileges or null == true
839 && unit.serviceConfig.CapabilityBoundingSet or null == ""
840 && unit.serviceConfig.MemorySwapMax or null == "0"
841 && unit.serviceConfig.Restart or null == "on-failure"
842 && builtins.elem "multi-user.target" unit.wantedBy
843 && unit.requires == [ ]
844 && unit.bindsTo == [ ];
845 in
846 !(confined receive && confined web)
847 || cfg.users.users.valley-web-receive.group != "valley-web"
848 || cfg.users.users.valley-web.group != "valley-web"
849 || receive.serviceConfig.User or null != "valley-web-receive"
850 || receive.serviceConfig.Group or null != "valley-web"
851 || receive.serviceConfig.StateDirectory or null != "valley-web"
852 || receive.serviceConfig.StateDirectoryMode or null != "0750"
853 || receive.serviceConfig.LoadCredential or [ ] != [ "token:/run/keys/valley-web-receiver-token" ]
854 || receive.serviceConfig.MemoryMax or null != "2G"
855 || !(lib.hasInfix "/bin/valley-web-receive --state /var/lib/valley-web/store --listen 192.0.2.10:8081 --instance valley-host --destination example.org --verifiers /nix/store/" receive.serviceConfig.ExecStart)
856 || !(lib.hasSuffix "-valley-web-verifiers --token-file %d/token --max-body 1G --max-upload 2G --max-storage 8G" receive.serviceConfig.ExecStart)
857 || web.serviceConfig.User or null != "valley-web"
858 || web.serviceConfig.Group or null != "valley-web"
859 || web.serviceConfig ? StateDirectory
860 || web.serviceConfig ? ReadWritePaths
861 || web.serviceConfig ? LoadCredential
862 || web.serviceConfig.ReadOnlyPaths or [ ] != [ "-/var/lib/valley-web" ]
863 || web.serviceConfig.MemoryMax or null != "1G"
864 || !(builtins.elem "valley-web-receive.service" web.after)
865 || !(lib.hasSuffix "/bin/valley-web --state /var/lib/valley-web/store --listen 127.0.0.1:8080" web.serviceConfig.ExecStart);
866in
867{
868 module-eval =
869 if failedAssertions != [ ] then
870 throw "valley module-eval: failed assertions: ${
871 lib.concatMapStringsSep "; " (a: a.message) failedAssertions
872 }"
873 else if resticRenderedWithoutDeclaration then
874 throw "valley module-eval: restic machinery rendered for a declaration without a backup block"
875 else if busRenderedWithoutEnable then
876 throw "valley module-eval: bus machinery rendered without services.valley.bus.enable"
877 else if
878 !(lib.any (a: lib.hasInfix "services.valley.backup." a.message) missingSecretAssertions)
879 then
880 throw "valley module-eval: enabling backup without the secret-path options must fail an assertion naming them"
881 else if unrefusedHosts != [ ] then
882 throw "valley module-eval: ${lib.concatMapStringsSep "; " (r: "a host was not refused although ${r.why}") unrefusedHosts}"
883 else if protectionRenderedWithoutDeclaration then
884 throw "valley module-eval: principal machinery rendered for a declaration with no protection block and no tagged key"
885 else if policyMissingWithoutDeclaration then
886 throw "valley module-eval: a project with no protection block got no pre-receive hook — the push policy is installed on every project a host serves"
887 else if protectedHost.config.services.openssh.settings ? PermitUserEnvironment then
888 throw "valley module-eval: sshd must pass no key's environment on: the git user's shell derives the principal from the authenticated key"
889 else if
890 !(lib.hasInfix "valley-git-shell" protectedHost.config.users.users.git.shell)
891 then
892 throw "valley module-eval: the git user's login shell must be the valley's, which derives the principal and pauses pushes until init converges"
893 else if integratorRenderedWithoutEnable then
894 throw "valley module-eval: integrator machinery rendered for a protected declaration that never enabled the service"
895 else if !(integratorHost.config.systemd.services ? "valley-integrator@") then
896 throw "valley module-eval: the integrator is enabled and no controller unit was rendered"
897 else if
898 controllers != [
899 "valley-integrator@guarded.service"
900 "valley-integrator@released.service"
901 "valley-integrator@sealed.service"
902 ]
903 then
904 throw "valley module-eval: a controller runs for each protected project and no other, not ${lib.concatStringsSep ", " controllers}"
905 else if
906 publishers != [
907 "valley-publish@guarded.path"
908 "valley-publish@released.path"
909 "valley-publish@sealed.path"
910 ]
911 then
912 throw "valley module-eval: each controller's landings are published by a path unit of its own, not ${lib.concatStringsSep ", " publishers}"
913 else if integratorHost.config.systemd.services."valley-publish@".serviceConfig.User != "git" then
914 throw "valley module-eval: a landing is published as the git user, which holds the mirror credentials"
915 else if integratorUser == integratorHost.config.services.valley.user then
916 throw "valley module-eval: the integrator must not run as the git user — it has its own (bd-500adf7)"
917 else if !(integratorHost.config.users.users ? ${integratorUser}) then
918 throw "valley module-eval: the integrator runs as ${integratorUser}, which the module never declares"
919 else if integratorHost.config.users.users.${integratorUser}.group != "git" then
920 throw "valley module-eval: the integrator reaches the repositories through the git group, and holds no other grant"
921 else if integratorSafeDirectory then
922 throw "valley module-eval: a controller must carry safe.directory for the one repository it serves in its own environment — it does not own the repositories, and git refuses what it does not own"
923 else if integratorFloor then
924 throw "valley module-eval: a controller must be told which repository carries the floor, and must carry a safe.directory exception for it — the floor is read from that repository's integrated tip, and git refuses a repository its caller does not own"
925 else if integratorScratch then
926 throw "valley module-eval: a controller's TMPDIR must be its state directory and that directory must be named in ReadWritePaths — under ProtectSystem=strict a path the unit does not enumerate is one it cannot write, and a verdict needs a worktree on disk"
927 else if identityRenderedWithoutEnable then
928 throw "valley module-eval: registry-compilation machinery rendered for a host that never enabled it — nothing may change until a consumer opts in"
929 else if identityCompiler then
930 throw "valley module-eval: the compiler must run as the git user, write only its own 0755 state directory, read the registry from the instance repository, write the grants the pre-receive hook reads, and have its authorized_keys added to what sshd reads under the %u token — sshd refuses a keys file owned by anyone but root or the account it authorizes, and a fixed path in that global list would authorize every registry key for every account on the host"
931 else if identityIntegrator then
932 throw "valley module-eval: a controller under a compiled registry must read the compiled signers file, start after the compilation, and sign under the name the registry publishes its key under"
933 else if signersRenderedWithoutIntegrator then
934 throw "valley module-eval: a signers publication rendered for a host whose integrator is off — there is no transfer statement to verify"
935 else if signersUnpublished then
936 throw "valley module-eval: the signers publisher must publish the controllers' own signers file and signing name into the instance repository, as the git user, writing nothing else, after valley-init and the compilation, at boot and whenever the signers file changes"
937 else if signerProjectsMisrendered then
938 throw "valley module-eval: a controller is given a signer projects file exactly when the host restricts a signer to projects"
939 else if identityKeepsDeclaredKeys then
940 throw "valley module-eval: the declared authorized keys must stay authorized beside the compiled ones — a compiled file that replaced them would make a bad compilation a locked-out git user"
941 else if workerRenderedWithoutEnable then
942 throw "valley module-eval: check-worker machinery rendered for a host that never enabled it — nothing, the nix daemon's slice included, may change until a consumer opts in"
943 else if buildSliceMisrendered then
944 throw "valley module-eval: the build slice must put the nix daemon in valley-builds.slice at the quota and memory cap the host names, with no swap, and render nothing of the worker"
945 else if workerMisrendered then
946 throw "valley module-eval: the check worker must run as its own account outside the git group, on one CPU, with one derivation built at a time on 4 cores, in a slice that holds it and the nix daemon to 4 CPUs and 8 GiB with no swap and no device policy, reaching this host's projects through its sshd under the host's own key, on a timer whose first pass waits five minutes after the timer starts and whose later passes are counted from the end of each pass"
947 else if restackerRenderedWithoutEnable then
948 throw "valley module-eval: restacker machinery rendered for a host that never enabled it"
949 else if restackerMisrendered then
950 throw "valley module-eval: each restacker controller must run valley-restacker run for its project as its own account outside the git group, with its own 0700 state directory as the only persistent path it may write, pushing over this host's sshd as its principal with the key systemd hands it as a credential, checking the host's own key, and reading the floor from the instance repository"
951 else if webPublisherRenderedWithoutEnable then
952 throw "valley module-eval: web publisher machinery rendered for a host that imports its module and never enabled it"
953 else if webPublisherMisrendered then
954 throw "valley module-eval: the web publisher must be a oneshot on a five-minute timer whose first pass waits five minutes and which no switch starts, run as a dynamic user in the git group with an empty safe.directory entry and then one exact entry per served repository, the repositories read-only, only its state and cache writable, the host's keys inaccessible and its memory capped with no swap, reading the instance repository and naming the host, the receiver, its token as a credential, the destination, the display mapping, the bounds on its bundles and storage, and the identity registry's directory"
955 else if webReceiverRenderedWithoutEnable then
956 throw "valley module-eval: web receiver machinery rendered for a host that imports its module and never enabled it"
957 else if webReceiverMisrendered then
958 throw "valley module-eval: the web receiver and valley-web must be two confined units started at boot, restarted on failure and requiring nothing of each other, as two users of the valley-web group, the receiver owning the state directory at 0750 with its token as a credential, its pinned verifiers, its caps and its own memory cap, and valley-web after it with the state directory read-only, no credential and a memory cap of its own"
959 else
960 pkgs.runCommand "valley-module-eval" {
961 initScript = host.config.systemd.services.valley-init.script;
962 sshdConfig = host.config.services.openssh.extraConfig;
963 resticService = host.config.systemd.units."restic-backups-valley.service".text;
964 resticTimer = host.config.systemd.units."restic-backups-valley.timer".text;
965 protectedInit = protectedHost.config.systemd.services.valley-init.script;
966 protectedKeys = lib.concatStringsSep "\n" protectedKeyLines;
967 protectedShell = protectedHost.config.users.users.git.shell;
968 integratorUnit = integratorHost.config.systemd.units."valley-integrator@.service".text;
969 integratorInit = integratorHost.config.systemd.services.valley-init.script;
970 publishUnit = host.config.systemd.units."valley-publish@.service".text;
971 identityInit = identityHost.config.systemd.services.valley-init.script;
972 passAsFile = [
973 "initScript"
974 "sshdConfig"
975 "resticService"
976 "resticTimer"
977 "protectedInit"
978 "protectedKeys"
979 "integratorUnit"
980 "integratorInit"
981 "publishUnit"
982 "identityInit"
983 ];
984 } (builtins.readFile ./module-eval.sh);
985}