gunk-dev/the-valley

packages.nix

sourcec14b0e68e9c3main's published tip history
48.6 KiB
1# Everything this flake builds: the valley command, the
2# formatter, the attestation helper, the integrator, the identity
3# compiler, the pre-receive hook's policy, the security-key signature
4# verifier. The flake wires these into packages, apps, and the checks that
5# drive them; nothing here knows about any of those outputs.
6{
7 pkgs,
8 lib,
9 # The commit the flake is built from: its full SHA, the SHA with -dirty
10 # after it for a tree with uncommitted changes, or null when nix knows no
11 # commit. Only the installed CLI's version stamp reads it.
12 rev ? null,
13}:
14rec {
15 # The CLI's version, which `valley --version` prints and self-update
16 # reads to tell which commit is installed (selfupdate/): cliVersion and
17 # the short commit, as 0.1.0-97db597. A dirty tree's has -dirty after
18 # it, and with no commit known it ends in -unknown, so neither names a
19 # commit.
20 cliVersion = "0.1.0";
21 version =
22 if rev == null then
23 "${cliVersion}-unknown"
24 else if lib.hasSuffix "-dirty" rev then
25 "${cliVersion}-${builtins.substring 0 7 rev}-dirty"
26 else
27 "${cliVersion}-${builtins.substring 0 7 rev}";
28
29 # What no Go build or test here reads: prose and .gitignore files. A Go
30 # package's source leaves them out, so editing a module's README rebuilds
31 # nothing.
32 unread = lib.fileset.fileFilter (f: f.hasExt "md" || f.name == ".gitignore") ../.;
33
34 # The parts of the approval module (approval/) that only the approval
35 # package builds and tests: its command, the PIV signer's C source and
36 # the fixtures. A module that imports the approval library leaves them
37 # out of its source.
38 approvalExtras = [
39 ../approval/cmd
40 ../approval/piv
41 ../approval/testdata
42 ];
43
44 # Every Go test file in the tree. No package's build reads one.
45 goTests = lib.fileset.fileFilter (f: lib.hasSuffix "_test.go" f.name) ../.;
46
47 # The programs a person or an agent runs on their own machine, by package
48 # name, each with the Go build its package is made from. flake.nix offers
49 # these packages (clientPackages), and the formatter, on aarch64-darwin as
50 # well as on x86_64-linux, and valley-darwin-build (nix/checks/darwin.nix)
51 # compiles each build for Darwin. The programs only a valley host or its
52 # web edge runs, such as the integrator, the push hook, the check worker
53 # and the web server, are offered on Linux alone.
54 clientPrograms = {
55 inherit
56 valley-flow
57 approval
58 sigverify
59 ;
60 valley = valley-unwrapped;
61 attest = attest-unwrapped;
62 identity = identity-unwrapped;
63 };
64
65 # The client packages by name: the client programs', and klaus, which is
66 # valley-flow's program under the package name an installed self-update
67 # builds.
68 clientPackages = lib.attrNames clientPrograms ++ [ "klaus" ];
69
70 # A Darwin build takes no cgo, the way valley-darwin-build compiles it, so
71 # that check compiles what a Mac runs. Elsewhere this is empty, and
72 # buildGoModule's default stands.
73 noCgoOnDarwin = lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin { CGO_ENABLED = 0; };
74
75 # A Go module of this repository, built as a package that runs no tests,
76 # with its unit tests beside it as the package's unit attribute.
77 #
78 # The package's source is what its build reads: the module's directory
79 # (dir) and the modules of this repository it uses (modules), which its
80 # go.mod replaces with their local directories, each in its place in the
81 # tree. Nothing shared this way is fetched. The source holds no test file
82 # and none of the files only the tests read (tests.reads), and the
83 # package's checkPhase is off. So an edit to a test, or to a file only the
84 # tests read, changes neither the package nor any check built on it.
85 #
86 # unit is the same build over the same source with the module's own tests
87 # and tests.reads added, and with its checkPhase on. The checkPhase runs
88 # go test, with the rest of tests: the tools the tests need, and what runs
89 # before and after them, such as go vet. Each module's unit is its unit
90 # check (nix/checks/), so its tests run in that check and in no package
91 # build.
92 #
93 # A file the tests read is in unit's source though it is prose, so a test
94 # may read the repository's documents.
95 #
96 # excluded names files of dir that neither the build nor the tests read:
97 # files only a flake check reads, or the part of a shared module that
98 # another package builds and tests.
99 goModule =
100 {
101 dir,
102 modules ? [ ],
103 excluded ? [ ],
104 tests ? { },
105 ...
106 }@args:
107 let
108 testReads = tests.reads or [ ];
109 source =
110 fileset:
111 lib.fileset.toSource {
112 root = ../.;
113 inherit fileset;
114 };
115 build = lib.fileset.difference (lib.fileset.unions ([ dir ] ++ modules)) (
116 lib.fileset.unions ([ unread goTests ] ++ excluded ++ testReads)
117 );
118 withTests = lib.fileset.union (lib.fileset.difference (lib.fileset.unions [
119 build
120 (lib.fileset.intersection goTests dir)
121 ]) (lib.fileset.unions ([ unread ] ++ excluded))) (lib.fileset.unions testReads);
122 in
123 pkgs.buildGoModule (
124 finalAttrs:
125 removeAttrs args [
126 "dir"
127 "modules"
128 "excluded"
129 "tests"
130 ]
131 // {
132 version = "0";
133 src = source build;
134 modRoot = lib.path.removePrefix ../. dir;
135 env = (args.env or { }) // noCgoOnDarwin;
136 # Standard library only, so no module is fetched.
137 vendorHash = null;
138 doCheck = false;
139 passthru.unit = finalAttrs.finalPackage.overrideAttrs (
140 prev:
141 removeAttrs tests [ "reads" ]
142 // {
143 pname = "${prev.pname}-unit";
144 src = source withTests;
145 doCheck = true;
146 }
147 );
148 }
149 );
150
151 # vendorHash = null builds in vendor mode, which has no reading of a local
152 # replace. The replaced module is a directory beside the program and
153 # nothing is fetched either way, so these builds read go.mod as written.
154 readsGoMod = ''
155 export GOFLAGS="''${GOFLAGS//-mod=vendor/-mod=mod}"
156 '';
157
158 # Markdown prose is filled paragraphs hard-wrapped at 100 columns
159 # (ida-1ec03b1). One flag string backs both the formatter app and the
160 # prose-format check, so the two cannot drift. Embedded-language
161 # formatting is off so fenced code blocks pass through byte-for-byte.
162 proseFmtArgs = "--prose-wrap always --print-width 100 --embedded-language-formatting off";
163
164 # The valley command (status/), the raw Go binary with nothing wrapped:
165 # the verbs that read a change's state from origin and write its record,
166 # review and approve, the plan graph's verbs, the bus's, checks and
167 # self-update. status reads one change's request and outcome record from
168 # origin, and prints them as sentences or as the valley-status/v1 JSON
169 # object front ends read. ready, unready and withdraw write a change's
170 # record, with the one reading of a record the push hook shares
171 # (../change). rebase rebases a change's whole stack and adds each
172 # change's rebased head to its record, through the rebase engine
173 # (../rebase), which also reads how far each version has landed for the
174 # listings. knot reads and writes the plan graph, with the one reading of
175 # a graph the push hook shares (../knot), and plan shows that graph as a
176 # view. review reads a version's file delta and its approved version's
177 # with the one reading of valley-delta-v1 (../delta). self-update
178 # installs the tip of a branch of the-valley into the user's nix profile
179 # (../selfupdate). checks prints which checks a change requires, as the
180 # deriver (../derive) derives them from the policy the composed-policy
181 # reader (../composed) reads. approve and review sign an approval, when
182 # an approval key is selected, in the approval format (../approval). On
183 # Linux a YubiKey's PIV slot signs through the PIV signer, fixed at build
184 # time as the approval command's is. The signer is Linux C, so elsewhere
185 # the binary carries none, and selecting a PIV slot is refused; a
186 # software key signs everywhere. Go, standard library only. It runs
187 # whatever git, cue, less, attest and nats are on PATH, so checks that
188 # put a failing stand-in for one ahead of it run this binary rather than
189 # a wrapper. Its unit tests hold its shell quoting to bash, so they need
190 # bash, lay pending out over real repositories, so they need git, and
191 # derive a change's checks under the verification schema, so they need
192 # cue and the schema. The plan's golden files (status/testdata/plan/) are
193 # valley-plan's, and no Go test reads them.
194 valley-unwrapped = goModule {
195 pname = "valley-unwrapped";
196 dir = ../status;
197 modules = [
198 ../approval
199 ../change
200 ../composed
201 ../delta
202 ../derive
203 ../knot
204 ../note
205 ../rebase
206 ../selfupdate
207 ../telemetry
208 ];
209 excluded = [ ../status/testdata/plan ] ++ approvalExtras;
210 preBuild = readsGoMod;
211 ldflags = lib.optionals pkgs.stdenv.hostPlatform.isLinux [
212 "-X main.pivSigner=${lib.getExe piv-signer}"
213 ];
214 tests = {
215 reads = [ ../schema/verification.cue ];
216 nativeCheckInputs = [
217 pkgs.bash
218 pkgs.git
219 pkgs.cue
220 ];
221 # A test that cannot find a tool it needs fails rather than skipping.
222 preCheck = ''
223 export VALLEY_TEST_TOOLS=required
224 '';
225 };
226 meta.mainProgram = "valley";
227 };
228
229 # The valley command with the tools it runs: git, natscli (tail and
230 # replay), cue (checks and approving, which compose the policy layers),
231 # less (review's notes) and attest (approving, which runs the checks and
232 # signs them). The verification schema travels with it, as it does with
233 # the integrator: only the-valley's own tree carries schema/, so a
234 # project's checkout has none to read. --set-default leaves an explicit
235 # VALLEY_VERIFICATION_SCHEMA in charge. It carries no stamp, so the
236 # packages the checks and the integrator use do not change with every
237 # commit.
238 valley-unstamped =
239 pkgs.runCommand "valley"
240 {
241 nativeBuildInputs = [ pkgs.makeWrapper ];
242 meta.mainProgram = "valley";
243 }
244 ''
245 mkdir -p $out/bin
246 makeWrapper ${lib.getExe valley-unwrapped} $out/bin/valley \
247 --prefix PATH : ${
248 lib.makeBinPath [
249 pkgs.git
250 pkgs.natscli
251 pkgs.cue
252 pkgs.less
253 attest
254 ]
255 } \
256 --set-default VALLEY_VERIFICATION_SCHEMA ${../schema/verification.cue}
257 '';
258
259 # The installed package: the valley command stamped with its version, the
260 # shell completions at the standard paths home-manager/NixOS auto-link,
261 # and the tiny policy self-update's smoke test derives checks from
262 # (examples/policy/smoke/). The stamp is set on this outer wrapper alone,
263 # so the packages the checks and the integrator use do not change with
264 # every commit. The name carries the version as well: nix profile names
265 # the element valley from it, and self-update reads a hand-installed
266 # valley's commit from it.
267 valley =
268 pkgs.runCommand "valley-${version}"
269 {
270 inherit version;
271 nativeBuildInputs = [
272 pkgs.makeWrapper
273 pkgs.installShellFiles
274 ];
275 meta.mainProgram = "valley";
276 }
277 ''
278 mkdir -p $out/bin $out/share/valley
279 makeWrapper ${lib.getExe valley-unstamped} $out/bin/valley \
280 --set VALLEY_VERSION ${version}
281 installShellCompletion --bash --name valley ${../completions/valley.bash}
282 installShellCompletion --zsh --name _valley ${../completions/_valley}
283 cp -r --no-preserve=mode ${../examples/policy/smoke} $out/share/valley/smoke-policy
284 '';
285
286 # The check worker: one pass of `valley work` (status/worker.go), which
287 # builds the nix checks ready changes require and publishes the evidence
288 # before anyone approves them. It runs this flake's git, cue and attest,
289 # and the verification schema travels with it, as it does with the CLI.
290 # nix is the machine's own, for the reason attest gives.
291 valley-worker =
292 pkgs.runCommand "valley-worker"
293 {
294 nativeBuildInputs = [ pkgs.makeWrapper ];
295 meta.mainProgram = "valley-worker";
296 }
297 ''
298 mkdir -p $out/bin
299 makeWrapper ${lib.getExe valley-unwrapped} $out/bin/valley-worker \
300 --add-flags work \
301 --prefix PATH : ${
302 lib.makeBinPath [
303 pkgs.git
304 pkgs.cue
305 attest
306 ]
307 } \
308 --set-default VALLEY_VERIFICATION_SCHEMA ${../schema/verification.cue}
309 '';
310
311 # `nix run .#fmt` — rewrap every tracked *.md in the repo to 100 columns.
312 # GNU xargs is pinned with git and prettier: a Mac's own takes no
313 # --no-run-if-empty.
314 prose-fmt = pkgs.writeShellApplication {
315 name = "valley-fmt";
316 runtimeInputs = [
317 pkgs.git
318 pkgs.prettier
319 pkgs.findutils
320 ];
321 text = ''
322 cd "$(git rev-parse --show-toplevel)"
323 git ls-files -z -- '*.md' | xargs -0 --no-run-if-empty \
324 prettier ${proseFmtArgs} --write
325 '';
326 };
327
328 # The Phase 2 attestation helper (dcr-0de694f). Go, standard library
329 # only, note format included, and hence no module fetch at build time.
330 # Its unit tests need git and ssh-keygen, and cue, which one test runs
331 # to show that a batch's statements are vetted each on its own. It reads
332 # signed notes, and writes and reads the statements in them and the
333 # valley-tree-v1 digests they name, with the note module (../note), the
334 # one reading of the envelope and its statement shared by the programs
335 # that write, verify and admit attestations. The conformance vectors
336 # (attest/conformance/) are attest-conformance's, and no Go test reads
337 # them.
338 attest-unwrapped = goModule {
339 pname = "valley-attest";
340 dir = ../attest;
341 modules = [
342 ../note
343 ../telemetry
344 ];
345 excluded = [ ../attest/conformance ];
346 preBuild = readsGoMod;
347 tests = {
348 nativeCheckInputs = [
349 pkgs.git
350 pkgs.openssh
351 pkgs.cue
352 ];
353 preCheck = ''
354 export ATTEST_CUE_TESTS=require
355 '';
356 };
357 meta.mainProgram = "attest";
358 };
359
360 # The shipping form. git and cue are pinned to this flake's nixpkgs,
361 # so every host composes and vets a statement with the same tools.
362 # Signing needs no tool at all: a note is signed on crypto/ed25519
363 # inside the binary. `nix` is deliberately NOT pinned: the check being
364 # attested to must be built by the nix the machine actually runs, and
365 # a nix carried in here would be a second one.
366 attest =
367 pkgs.runCommand "valley-attest"
368 {
369 nativeBuildInputs = [ pkgs.makeWrapper ];
370 meta.mainProgram = "attest";
371 }
372 ''
373 mkdir -p $out/bin
374 makeWrapper ${lib.getExe attest-unwrapped} $out/bin/attest \
375 --prefix PATH : ${
376 lib.makeBinPath [
377 pkgs.git
378 pkgs.cue
379 ]
380 } \
381 --set-default VALLEY_ATTEST_SCHEMA ${../schema/attestation.cue}
382 '';
383
384 # The identity registry compiler (dcr-b87f6e8). Go, standard library
385 # only, note format included, same trade as attest and the integrator, so
386 # no module is fetched. It reads the registry's export with exactjson
387 # (../exactjson), and opens each approval signers file with the
388 # approval format's authority stamp (../approval), which names refs by
389 # the change record's branch rule (../change). Its unit tests pin the
390 # note format's key hash
391 # against the reference vector attest is held to, and verify a real
392 # YubiKey attestation against the Yubico roots it carries. The test
393 # vectors (identity/testdata/) are read by the tests and by identity-e2e,
394 # never by the build. One test compiles a registry in a real repository
395 # while a push moves its ref, so the tests run git and cue and read the
396 # schema.
397 identity-unwrapped = goModule {
398 pname = "valley-identity";
399 dir = ../identity;
400 modules = [
401 ../approval
402 ../change
403 ../note
404 ../exactjson
405 ];
406 # Of the approval module, only its library is read.
407 excluded = approvalExtras;
408 preBuild = readsGoMod;
409 tests.reads = [
410 ../identity/testdata
411 ../schema/identity.cue
412 ];
413 tests.nativeCheckInputs = [
414 pkgs.git
415 pkgs.cue
416 ];
417 meta.mainProgram = "identity";
418 };
419
420 # The shipping form. git reads the registry out of the instance
421 # repository's tip and cue vets and exports it, both pinned to this
422 # flake's nixpkgs so every host compiles a registry the same way. The
423 # schema travels with the binary: a compiler judging a registry against a
424 # schema the consumer supplied would be no floor at all.
425 identity =
426 pkgs.runCommand "valley-identity"
427 {
428 nativeBuildInputs = [ pkgs.makeWrapper ];
429 meta.mainProgram = "identity";
430 }
431 ''
432 mkdir -p $out/bin
433 makeWrapper ${lib.getExe identity-unwrapped} $out/bin/identity \
434 --prefix PATH : ${
435 lib.makeBinPath [
436 pkgs.git
437 pkgs.cue
438 ]
439 } \
440 --set-default VALLEY_IDENTITY_SCHEMA ${../schema/identity.cue}
441 '';
442
443 # The security-key signature verifier (sigverify/README.md). Go,
444 # standard library only, so no module is fetched.
445 #
446 # The git its git-tag command runs is fixed at build time to this
447 # flake's git, as an absolute store path compiled into the binary. A
448 # wrapper that puts git on PATH would leave the binary inside it looking
449 # git up on PATH, and a caller's environment could change which git that
450 # is. Compiled in, there is no PATH lookup to change.
451 #
452 # Its tests run against real ssh-keygen and git. The security-key cases
453 # among them need OpenSSH's sk-dummy authenticator, which the
454 # sigverify-unit check supplies. Building this package runs no test, so a
455 # consumer building it never builds OpenSSH.
456 sigverify = goModule {
457 pname = "valley-sigverify";
458 dir = ../sigverify;
459 ldflags = [ "-X main.gitProgram=${lib.getExe pkgs.git}" ];
460 tests.nativeCheckInputs = [
461 pkgs.git
462 pkgs.openssh
463 ];
464 meta.mainProgram = "sigverify";
465 };
466
467 # Telemetry (../telemetry): the diagnostic records, the bounded streams
468 # that hold them and the telemetry command's grammar, which the
469 # producers, the git user's shell and the collector share, and the
470 # collector itself, valley-telemetry serve, which the host runs per
471 # connection to its socket. Go, standard library only.
472 telemetry = goModule {
473 pname = "valley-telemetry";
474 dir = ../telemetry;
475 meta.mainProgram = "valley-telemetry";
476 };
477
478 # The reason a failed push is logged with (../pushreason): git's error
479 # output made one line fit for the journal and telemetry. The mirror
480 # pusher a host renders hands it what git printed. Go, standard library
481 # only.
482 pushreason = goModule {
483 pname = "valley-pushreason";
484 dir = ../pushreason;
485 meta.mainProgram = "pushreason";
486 };
487
488 # The bridge behind a host's services.valley.onMain binding (../onmain):
489 # it starts one unit when a project's main moves. Go, standard library
490 # only. The git it reads the repository with is compiled in, as
491 # sigverify's is, so no PATH changes which git that is. Its tests run
492 # against real git.
493 onmain = goModule {
494 pname = "valley-onmain";
495 dir = ../onmain;
496 ldflags = [ "-X main.gitProgram=${lib.getExe pkgs.git}" ];
497 tests.nativeCheckInputs = [ pkgs.git ];
498 meta.mainProgram = "onmain";
499 };
500
501 # The pre-receive hook's policy (valleyhook/): what a push may write to a
502 # project a valley host serves. It validates a push to the plan graph
503 # with the one reading of a graph the CLI shares (../knot), reads a
504 # pushed approval with the approval format (../approval), and reads the
505 # project's push policy with the push policy reader (../pushpolicy),
506 # which reads with exactjson (../exactjson). The same
507 # binary is the git user's login shell, which derives the pushing
508 # principal and pauses pushes until the host has converged. Go, standard
509 # library only, so no module is fetched.
510 #
511 # The git it reads the repository with is fixed at build time, the way
512 # sigverify's is: an absolute store path compiled into the binary, so no
513 # PATH a hook runs under can change which git that is.
514 valleyhook = goModule {
515 pname = "valley-valleyhook";
516 dir = ../valleyhook;
517 modules = [
518 ../approval
519 ../note
520 ../change
521 ../knot
522 ../pushpolicy
523 ../exactjson
524 ../telemetry
525 ];
526 # The approval library alone: its command, signer and fixtures are the
527 # approval package's.
528 excluded = approvalExtras;
529 preBuild = readsGoMod;
530 ldflags = [ "-X main.gitProgram=${lib.getExe pkgs.git}" ];
531 # The walk's and the change records' tests build hostile objects with
532 # real git.
533 tests.nativeCheckInputs = [ pkgs.git ];
534 meta.mainProgram = "valleyhook";
535 };
536
537 # The PIV session signer (approval/piv/): a small C program on libykpiv
538 # that holds a YubiKey exclusively for a run of approval signatures,
539 # asks for the PIN once on the terminal, and signs each statement with a
540 # touch. It is C so that the Go modules stay standard library only: the
541 # approval command runs it rather than linking a smart card library. It
542 # calls pcsc-lite, libykpiv's own transport, directly only to connect
543 # exclusively and to see a reset. libykpiv reconnects after a reset or a
544 # removal (_ykpiv_begin_transaction) in shared mode; the signer's
545 # libykpiv reconnects exclusively, so no command reaches the card over a
546 # shared connection even when the card changes between the helper's
547 # check and libykpiv's call. nixpkgs' default hardening applies.
548 piv-signer = pkgs.stdenv.mkDerivation {
549 pname = "valley-piv-signer";
550 version = "0";
551 src = ../approval/piv;
552 buildInputs = [
553 (pkgs.yubico-piv-tool.overrideAttrs (old: {
554 postPatch = (old.postPatch or "") + ''
555 substituteInPlace lib/ykpiv.c \
556 --replace-fail 'SCardReconnect(state->card, SCARD_SHARE_SHARED,' \
557 'SCardReconnect(state->card, SCARD_SHARE_EXCLUSIVE,' \
558 --replace-fail 'SCardConnect(state->context, state->reader, SCARD_SHARE_SHARED,' \
559 'SCardConnect(state->context, state->reader, SCARD_SHARE_EXCLUSIVE,'
560 '';
561 }))
562 pkgs.pcsclite
563 ];
564 buildPhase = ''
565 $CC -std=c11 -O2 -Wall -Wextra -Werror -o valley-piv-signer valley-piv-signer.c \
566 -I${lib.getDev pkgs.pcsclite}/include/PCSC -lykpiv -lpcsclite
567 '';
568 installPhase = ''
569 install -Dm755 valley-piv-signer $out/bin/valley-piv-signer
570 '';
571 meta.mainProgram = "valley-piv-signer";
572 };
573
574 # Approval statements (approval/): the-valley/approval/v1's written form,
575 # signing it with a software key or a YubiKey's PIV slot, and verifying
576 # an approval note under the approval signers files. Go, standard library
577 # only. On Linux the PIV signer it runs is fixed at build time, the way
578 # sigverify's git is: an absolute store path compiled into the binary.
579 # The signer is Linux C, so elsewhere the binary carries none, and
580 # `sign --piv` is refused; a software key signs everywhere. Its unit
581 # tests run that signer with no smart card service to reach, so no device
582 # is touched.
583 approval = goModule {
584 pname = "valley-approval";
585 dir = ../approval;
586 modules = [
587 ../note
588 ../change
589 ];
590 excluded = [ ../approval/piv ];
591 subPackages = [ "cmd/approval" ];
592 preBuild = readsGoMod;
593 ldflags = lib.optionals pkgs.stdenv.hostPlatform.isLinux [
594 "-X main.pivSigner=${lib.getExe piv-signer}"
595 ];
596 tests = {
597 reads = [ ../approval/testdata ];
598 subPackages = [
599 "."
600 "cmd/approval"
601 ];
602 VALLEY_PIV_SIGNER = lib.getExe piv-signer;
603 };
604 meta.mainProgram = "approval";
605 };
606
607 # The note envelope (note/). Its tests hold it to refusing every line a
608 # relayer could append that one of its readers would refuse.
609 note = goModule {
610 pname = "valley-note";
611 dir = ../note;
612 };
613
614 # The strict JSON reading (exactjson/) that the identity compiler, the
615 # pre-receive hook and read access read CUE's exports with: every key
616 # spelled exactly as the field it is read into, and no key twice in one
617 # object. Its tests
618 # hold it to each spelling encoding/json alone would fold into a field.
619 exactjson = goModule {
620 pname = "valley-exactjson";
621 dir = ../exactjson;
622 };
623
624 # A project's push policy (pushpolicy/), read exactly as the pre-receive
625 # hook reads it: the file the host module writes per project, held to
626 # exactjson's spelling, and the hook's pattern matching. Its tests hold
627 # it to both.
628 pushpolicy = goModule {
629 pname = "valley-pushpolicy";
630 dir = ../pushpolicy;
631 modules = [ ../exactjson ];
632 preBuild = readsGoMod;
633 };
634
635 # The web UI (web/). Package export is the contract between the
636 # publisher on a valley host and the web server it pushes to: the public
637 # export and the projection onto it, the signed manifest, the upload and
638 # the receiver's state directory. It reads names and IDs by the plan
639 # graph's rules (../knot), the manifest with the note module (../note),
640 # and who may read a project through ../readaccess, which reads with
641 # ../exactjson, as the publisher reads the host declaration and package
642 # export reads export.json. The program
643 # built from it is the publisher, cmd/valley-web-publish, which
644 # valley-web-publish below wraps. The server and its command are built by
645 # valley-web below, and the receiver by valley-web-receive. The export's
646 # tests accept bundles and build the shared fixture's repositories with
647 # real git. The publisher's tests run it against a valley built with real
648 # git and the valley command's raw binary, read each project's policy/read and the instance's identity
649 # registry with cue under schema/read.cue and schema/identity.cue, and
650 # upload to a receiver over a real store, and to the real receiver, whose
651 # state directory the real valley-web serves. One lands a change as the
652 # integrator does, with a transfer statement attest signs under a key
653 # ssh-keygen makes, which the CLI verifies with attest. Each test's host
654 # declaration is exported by cue under schema/valley.cue, as the module
655 # exports the host's. go vet runs after them. The fixture's expected
656 # export (export/exporttest/testdata/) is read by the tests alone, and so
657 # are README.md and docs/, whose links package markdown's tests resolve. Go,
658 # standard library only, so no module is fetched.
659 web = goModule {
660 pname = "valley-web-module";
661 dir = ../web;
662 modules = [
663 ../knot
664 ../note
665 ../readaccess
666 ../exactjson
667 ];
668 excluded = [
669 ../web/server
670 ../web/readerstate
671 ../web/cmd/valley-web
672 ../web/cmd/valley-web-receive
673 ];
674 preBuild = readsGoMod;
675 tests = {
676 reads = [
677 ../web/export/exporttest/testdata
678 ../README.md
679 ../docs
680 ../schema/read.cue
681 ../schema/identity.cue
682 ../schema/valley.cue
683 ];
684 nativeCheckInputs = [
685 pkgs.git
686 pkgs.bash
687 pkgs.cue
688 pkgs.openssh
689 valley-unwrapped
690 attest
691 ];
692 # A test that cannot find a tool it needs fails rather than skipping.
693 preCheck = ''
694 export VALLEY_TEST_TOOLS=required
695 export VALLEY_WEB=${lib.getExe valley-web}
696 export VALLEY_WEB_RECEIVE=${lib.getExe valley-web-receive}
697 '';
698 postCheck = ''
699 go vet ./...
700 '';
701 };
702 meta.mainProgram = "valley-web-publish";
703 };
704
705 # Read access (readaccess/): the two consents a principal needs to read a
706 # project, read out of git commits with cue under schema/read.cue and
707 # schema/identity.cue, and the evaluator that intersects them. The web
708 # publisher reads through it, and its command is the coverage report,
709 # which valley-read-coverage below wraps. It reads cue's exports with
710 # exactjson (../exactjson). Its tests read real commits with real git and
711 # the real cue under both schemas, and go vet runs after them. Go,
712 # standard library only, so no module is fetched.
713 readaccess = goModule {
714 pname = "valley-readaccess";
715 dir = ../readaccess;
716 modules = [ ../exactjson ];
717 preBuild = readsGoMod;
718 tests = {
719 reads = [
720 ../schema/read.cue
721 ../schema/identity.cue
722 ];
723 nativeCheckInputs = [
724 pkgs.git
725 pkgs.cue
726 ];
727 # A test that cannot find a tool it needs fails rather than skipping.
728 preCheck = ''
729 export VALLEY_TEST_TOOLS=required
730 '';
731 postCheck = ''
732 go vet ./...
733 '';
734 };
735 meta.mainProgram = "valley-read-coverage";
736 };
737
738 # The coverage report: which projects a principal cannot read at a
739 # destination, and which consent each lacks. It runs this flake's git and
740 # cue, and both schemas travel with it.
741 valley-read-coverage =
742 pkgs.runCommand "valley-read-coverage"
743 {
744 nativeBuildInputs = [ pkgs.makeWrapper ];
745 meta.mainProgram = "valley-read-coverage";
746 }
747 ''
748 mkdir -p $out/bin
749 makeWrapper ${lib.getExe readaccess} $out/bin/valley-read-coverage \
750 --prefix PATH : ${
751 lib.makeBinPath [
752 pkgs.git
753 pkgs.cue
754 ]
755 } \
756 --set-default VALLEY_READ_SCHEMA ${../schema/read.cue} \
757 --set-default VALLEY_IDENTITY_SCHEMA ${../schema/identity.cue}
758 '';
759
760 # The web UI's server (web/server/) and its command, valley-web
761 # (web/cmd/valley-web/), which serves the active export of a receiver's
762 # state directory to its readers, and keeps their sessions in the
763 # browser state (web/readerstate/). It reads the export and the
764 # state directory with package export, so its source is the web
765 # module, less the fixture's expected export, which only web's tests
766 # read. Package export reads export.json with ../exactjson, so its
767 # source holds that module too. Of ../readaccess, which the publisher
768 # reads through and the server does not, it reads the go.mod alone,
769 # which go reads to resolve the module. The git it reads repositories
770 # with is fixed at build time, the way valleyhook's is. Its tests run the real program over the shared
771 # fixture and real git, and the server over the real publisher's output
772 # (web-published), and go vet runs after them. The crash tests and the
773 # browser test are skipped there: web-reader-state-crash and
774 # web-reader-browser-e2e (nix/checks/) run them from the same tests.
775 # Go, standard library only, so no module is fetched.
776 valley-web = goModule {
777 pname = "valley-web";
778 dir = ../web;
779 modules = [
780 ../knot
781 ../note
782 ../readaccess/go.mod
783 ../exactjson
784 ];
785 excluded = [
786 ../web/export/exporttest/testdata
787 ../web/cmd/valley-web-publish
788 ../web/cmd/valley-web-receive
789 ];
790 subPackages = [ "cmd/valley-web" ];
791 preBuild = readsGoMod;
792 ldflags = [ "-X the-valley/web/export.GitProgram=${lib.getExe pkgs.git}" ];
793 tests = {
794 subPackages = [
795 "server"
796 "readerstate"
797 "cmd/valley-web"
798 ];
799 checkFlags = [ "-skip=^(TestCrash|TestBrowser)" ];
800 nativeCheckInputs = [ pkgs.git ];
801 # A test that cannot find the publisher's output fails rather than
802 # skipping.
803 preCheck = ''
804 export VALLEY_TEST_TOOLS=required
805 export VALLEY_WEB_PUBLISHED=${web-published}
806 '';
807 postCheck = ''
808 go vet ./server/... ./readerstate/... ./cmd/valley-web/...
809 '';
810 };
811 meta.mainProgram = "valley-web";
812 };
813
814 # The real publisher's signed output over a small valley with a public
815 # project, two private projects each one named reader may read, and a
816 # project with no effective reader, written with --out by the packaged publisher and CLI
817 # (nix/checks/web-published.sh). valley-web's tests read it, so the
818 # server is tested against what the publisher writes. It is no check of
819 # its own.
820 web-published =
821 pkgs.runCommand "valley-web-published"
822 {
823 nativeBuildInputs = [
824 pkgs.git
825 pkgs.cue
826 pkgs.jq
827 valley-unstamped
828 valley-web-publish
829 ];
830 schema = ../schema/valley.cue;
831 }
832 (builtins.readFile ./checks/web-published.sh);
833
834 # The web export receiver, valley-web-receive (web/cmd/valley-web-receive/),
835 # which takes the publisher's uploads into a state directory that
836 # valley-web serves. Its source is the web module less the publisher,
837 # the server and its command, which it does not build, and the fixture's
838 # expected export. Package export reads export.json with ../exactjson, so
839 # its source holds that module too; of ../readaccess it reads the go.mod
840 # alone, as valley-web does. The git it accepts bundles with is fixed at
841 # build time. Its tests run the real program over the shared fixture and
842 # real git, with the real valley-web serving its state directory, and go
843 # vet runs after them. Go, standard library only.
844 valley-web-receive = goModule {
845 pname = "valley-web-receive";
846 dir = ../web;
847 modules = [
848 ../knot
849 ../note
850 ../readaccess/go.mod
851 ../exactjson
852 ];
853 excluded = [
854 ../web/export/exporttest/testdata
855 ../web/cmd/valley-web-publish
856 ../web/cmd/valley-web
857 ../web/server
858 ../web/readerstate
859 ];
860 subPackages = [ "cmd/valley-web-receive" ];
861 preBuild = readsGoMod;
862 ldflags = [ "-X the-valley/web/export.GitProgram=${lib.getExe pkgs.git}" ];
863 tests = {
864 nativeCheckInputs = [ pkgs.git ];
865 # A test that cannot find valley-web fails rather than skipping.
866 preCheck = ''
867 export VALLEY_TEST_TOOLS=required
868 export VALLEY_WEB=${lib.getExe valley-web}
869 '';
870 postCheck = ''
871 go vet ./cmd/valley-web-receive/...
872 '';
873 };
874 meta.mainProgram = "valley-web-receive";
875 };
876
877 # The edge's container image, for a web server that does not run NixOS:
878 # valley-web and valley-web-receive, and the git both run, in one image.
879 # The two run as two containers of it over one state directory, as two
880 # users of one group: the receiver as valley-web-receive, which writes
881 # the directory, and valley-web as valley-web, which reads it. The image
882 # names both users in its /etc/passwd, and holds the state directory,
883 # owned by the receiver and readable by the group alone, so a volume
884 # mounted there starts with that owner and mode. In it, browser/ is
885 # valley-web's alone, mode 0700: the browser state, the one place
886 # valley-web writes. It runs as valley-web unless it is told otherwise,
887 # and starts no program of its own: each container names its command.
888 edgeUsers = {
889 receiver = {
890 name = "valley-web-receive";
891 uid = 990;
892 };
893 web = {
894 name = "valley-web";
895 uid = 991;
896 };
897 gid = 990;
898 };
899 valley-web-image = pkgs.dockerTools.buildLayeredImage {
900 name = "valley-web";
901 contents = [
902 valley-web
903 valley-web-receive
904 (pkgs.dockerTools.fakeNss.override {
905 extraPasswdLines = with edgeUsers; [
906 "${receiver.name}:x:${toString receiver.uid}:${toString gid}:valley-web-receive:/var/empty:/bin/false"
907 "${edgeUsers.web.name}:x:${toString edgeUsers.web.uid}:${toString gid}:valley-web:/var/empty:/bin/false"
908 ];
909 extraGroupLines = [ "valley-web:x:${toString edgeUsers.gid}:" ];
910 })
911 ];
912 fakeRootCommands = ''
913 mkdir -p var/lib/valley-web/browser tmp
914 chown ${toString edgeUsers.receiver.uid}:${toString edgeUsers.gid} var/lib/valley-web
915 chmod 0750 var/lib/valley-web
916 chown ${toString edgeUsers.web.uid}:${toString edgeUsers.gid} var/lib/valley-web/browser
917 chmod 0700 var/lib/valley-web/browser
918 chmod 1777 tmp
919 '';
920 config = {
921 User = edgeUsers.web.name;
922 WorkingDirectory = "/";
923 Env = [ "PATH=/bin" ];
924 Volumes."/var/lib/valley-web" = { };
925 };
926 };
927
928 # The web publisher: one pass of valley-web-publish, which reads a valley
929 # host's public projects through the CLI's JSON commands and uploads them
930 # to a web receiver. It runs this flake's git, cue and CLI, and the two
931 # schemas it reads read access under travel with it, as the verification
932 # schema does with the CLI.
933 valley-web-publish =
934 pkgs.runCommand "valley-web-publish"
935 {
936 nativeBuildInputs = [ pkgs.makeWrapper ];
937 meta.mainProgram = "valley-web-publish";
938 }
939 ''
940 mkdir -p $out/bin
941 makeWrapper ${lib.getExe web} $out/bin/valley-web-publish \
942 --prefix PATH : ${
943 lib.makeBinPath [
944 pkgs.git
945 pkgs.cue
946 valley-unstamped
947 ]
948 } \
949 --set-default VALLEY_READ_SCHEMA ${../schema/read.cue} \
950 --set-default VALLEY_IDENTITY_SCHEMA ${../schema/identity.cue}
951 '';
952
953 # The plan graph (knot/): its canonical form, its layout, cycles and
954 # transitions, held by its own tests. The package is knotcheck, which
955 # knot-agree runs to hold the Go validator to the CUE schema and the
956 # knowledge lint.
957 knot = goModule {
958 pname = "valley-knot";
959 dir = ../knot;
960 meta.mainProgram = "knotcheck";
961 };
962
963 # The rebase engine (rebase/): a family of stacked changes captured from
964 # one snapshot of origin, rebased in a throwaway worktree, and published
965 # as one atomic branch push and one record append per change. It verifies
966 # the integrator's transfer statements with the note module (../note).
967 # Its tests run against real repositories, real pushes and real git, with
968 # go vet after them. Go, standard library only, so no module is fetched.
969 rebase = goModule {
970 pname = "valley-rebase";
971 dir = ../rebase;
972 modules = [
973 ../change
974 ../note
975 ];
976 preBuild = readsGoMod;
977 tests = {
978 nativeCheckInputs = [ pkgs.git ];
979 postCheck = ''
980 go vet ./...
981 '';
982 };
983 };
984
985 # Self-update (selfupdate/): the installed CLI brought up to the tip of a
986 # branch, built with nix and installed into the user's profile. Its tests,
987 # with go vet after them, use a real bare repository for ls-remote and a
988 # stand-in for nix whose builds are small scripts, so nothing is built and
989 # no profile is touched. Go, standard library only, so no module is
990 # fetched.
991 selfupdate = goModule {
992 pname = "valley-selfupdate";
993 dir = ../selfupdate;
994 tests = {
995 nativeCheckInputs = [ pkgs.git ];
996 postCheck = ''
997 go vet ./...
998 '';
999 };
1000 };
1001
1002 # The deriver of required checks (derive/): a change's paths read from
1003 # git diff -z, globs matched byte by byte, and the required checks, pins,
1004 # carry mode and unclassified paths derived from the whole composed
1005 # policy (../composed). Its tests, with go vet after them, derive over the
1006 # repository's own policy and the example policies, with changes drawn
1007 # from a fixed seed, so they read the schema and those policies, and need
1008 # git and cue. Go, standard library only, so no module is fetched.
1009 derive = goModule {
1010 pname = "valley-derive";
1011 dir = ../derive;
1012 modules = [ ../composed ];
1013 preBuild = readsGoMod;
1014 tests = {
1015 reads = [
1016 ../schema/verification.cue
1017 ../examples/policy
1018 ../policy/project
1019 ];
1020 nativeCheckInputs = [
1021 pkgs.git
1022 pkgs.cue
1023 ];
1024 # A test that cannot find a tool it needs fails rather than skipping.
1025 preCheck = ''
1026 export VALLEY_TEST_TOOLS=required
1027 '';
1028 postCheck = ''
1029 go vet ./...
1030 '';
1031 };
1032 };
1033
1034 # The composed-policy reader (composed/): each layer read out of git,
1035 # present, absent or refused. Its tests
1036 # read layers from real repositories, some with objects removed, and go
1037 # vet runs after them.
1038 composed = goModule {
1039 pname = "valley-composed";
1040 dir = ../composed;
1041 tests = {
1042 nativeCheckInputs = [ pkgs.git ];
1043 # A test that cannot find git fails rather than skipping.
1044 preCheck = ''
1045 export VALLEY_TEST_TOOLS=required
1046 '';
1047 postCheck = ''
1048 go vet ./...
1049 '';
1050 };
1051 };
1052
1053 # The change record (change/). Its tests cover its strict reading, its
1054 # fuzz target's seed corpus, and its branch-name rule, which they hold to
1055 # real git's check-ref-format.
1056 change = goModule {
1057 pname = "valley-change";
1058 dir = ../change;
1059 tests.nativeCheckInputs = [ pkgs.git ];
1060 };
1061
1062 # valley-delta-v1 (delta/): the encoding's strict reading, and the delta
1063 # read from real trees. Its unit tests run go vet, the conformance
1064 # vectors' script in its --check mode, which holds the committed expected
1065 # results to what the script computes, and go test, which builds each
1066 # vector's trees with real git and holds the Go code to those results.
1067 delta = goModule {
1068 pname = "valley-delta";
1069 dir = ../delta;
1070 tests = {
1071 reads = [ ../delta/testdata ];
1072 nativeCheckInputs = [
1073 pkgs.git
1074 pkgs.python3
1075 ];
1076 preCheck = ''
1077 go vet ./...
1078 python3 -I testdata/vectors.py --check testdata
1079 '';
1080 };
1081 };
1082
1083 # Review records (review/): the-valley/review/v1's strict reading, a
1084 # review's binding to the version it judged, recomputed from git within a
1085 # budget, and the append-only history a review is kept in, with the check
1086 # an append is held to. It reads change records with the one reading of a
1087 # record the push hook shares (../change), and the delta with
1088 # valley-delta-v1's bounded reading (../delta). Its tests build every
1089 # repository they read with real git and run its fuzz target's seed
1090 # corpus, and go vet runs after them. Go, standard library only, so no
1091 # module is fetched.
1092 review = goModule {
1093 pname = "valley-review";
1094 dir = ../review;
1095 modules = [
1096 ../change
1097 ../delta
1098 ];
1099 preBuild = readsGoMod;
1100 tests = {
1101 nativeCheckInputs = [ pkgs.git ];
1102 postCheck = ''
1103 go vet ./...
1104 '';
1105 };
1106 };
1107
1108 # The restacker (restack/): `valley-restacker run` reconciles on an
1109 # interval, and `once` is one pass. A pass reads origin through the
1110 # rebase engine (../rebase), plans which families to restack and which
1111 # to hold, keeps the writes in its journal, and pushes them;
1112 # `once --report-only` pushes none. It reads the cap on its
1113 # automatic versions through the composed-policy reader it shares with
1114 # the integrator (../composed), and a signer projects file through the
1115 # note module (../note). Its unit tests cover request association,
1116 # outcome currency, capacity and report bounds, and, against real git,
1117 # the journal of writes, recovery's decisions and publishing through the
1118 # rendered hook, its environment, its
1119 # scratch repository's identity, its state directory's lock and binding,
1120 # and the deadline on what it runs. go vet runs after them. Go, standard
1121 # library only, so no module is fetched.
1122 restack-unwrapped = goModule {
1123 pname = "valley-restacker";
1124 dir = ../restack;
1125 modules = [
1126 ../change
1127 ../composed
1128 ../note
1129 ../rebase
1130 ];
1131 # The program alone: e2e/transport is a module of restack-e2e's own,
1132 # which neither this build nor its tests read.
1133 excluded = [ ../restack/e2e ];
1134 subPackages = [ "." ];
1135 preBuild = readsGoMod;
1136 tests = {
1137 nativeCheckInputs = [ pkgs.git ];
1138 postCheck = ''
1139 go vet ./...
1140 '';
1141 };
1142 # The module is named for its directory; the program, for what it is.
1143 postInstall = ''
1144 mv $out/bin/restack $out/bin/valley-restacker
1145 '';
1146 meta.mainProgram = "valley-restacker";
1147 };
1148
1149 # The shipping form: git to read origin and cue to compose the policy,
1150 # both pinned to this flake's nixpkgs, with the packaged verification
1151 # schema as the default.
1152 valley-restacker =
1153 pkgs.runCommand "valley-restacker"
1154 {
1155 nativeBuildInputs = [ pkgs.makeWrapper ];
1156 meta.mainProgram = "valley-restacker";
1157 }
1158 ''
1159 mkdir -p $out/bin
1160 makeWrapper ${lib.getExe restack-unwrapped} $out/bin/valley-restacker \
1161 --prefix PATH : ${
1162 lib.makeBinPath [
1163 pkgs.git
1164 pkgs.cue
1165 ]
1166 } \
1167 --set-default VALLEY_VERIFICATION_SCHEMA ${../schema/verification.cue}
1168 '';
1169
1170 # The Phase 3 integrator (dcr-439b771). Go, standard library only,
1171 # same trade as attest, so no module is fetched. It reads change records
1172 # with the one reading of a record the push hook shares (../change),
1173 # verifier keys with the one reading of a key the note format defines
1174 # (../note), and derives required checks with the deriver (../derive).
1175 # The instance identity it publishes is the approval format's
1176 # (../approval).
1177 integrator-unwrapped = goModule {
1178 pname = "valley-integrator";
1179 dir = ../integrator;
1180 modules = [
1181 ../approval
1182 ../change
1183 ../composed
1184 ../derive
1185 ../note
1186 ../telemetry
1187 ];
1188 # The scenarios (integrator/e2e/) are integrator-e2e's, and no Go test
1189 # reads them. Of the approval module, only its library is read.
1190 excluded = [ ../integrator/e2e ] ++ approvalExtras;
1191 preBuild = readsGoMod;
1192 tests = {
1193 # The policy bridge's tests compose a policy under the verification
1194 # schema with real cue, and derive over diffs in real git.
1195 reads = [ ../schema/verification.cue ];
1196 nativeCheckInputs = [
1197 pkgs.git
1198 pkgs.cue
1199 ];
1200 };
1201 meta.mainProgram = "integrator";
1202 };
1203
1204 # The shipping form. The integrator drives four programs rather than
1205 # reimplementing what they do: attest judges every statement and
1206 # every note, cue composes the policy, git holds the requests and the
1207 # refs, and nats publishes its events. All four are pinned to this
1208 # flake's nixpkgs so an instance's integrators agree; `nix` is
1209 # deliberately absent for the same reason it is absent from attest —
1210 # a closure must be recomputed by the nix the machine actually runs.
1211 integrator =
1212 pkgs.runCommand "valley-integrator"
1213 {
1214 nativeBuildInputs = [ pkgs.makeWrapper ];
1215 meta.mainProgram = "integrator";
1216 }
1217 ''
1218 mkdir -p $out/bin
1219 makeWrapper ${lib.getExe integrator-unwrapped} $out/bin/integrator \
1220 --prefix PATH : ${
1221 lib.makeBinPath [
1222 pkgs.git
1223 pkgs.cue
1224 pkgs.natscli
1225 attest
1226 ]
1227 } \
1228 --set-default VALLEY_ATTEST_SCHEMA ${../schema/attestation.cue} \
1229 --set-default VALLEY_VERIFICATION_SCHEMA ${../schema/verification.cue} \
1230 --set-default VALLEY_EVENT_SCHEMA ${../schema/events.cue}
1231 '';
1232
1233 # valley-flow (flow/), the client that launches and follows agent runs:
1234 # the one module of this repository that imports third-party modules
1235 # (AGENTS.md, "Go dependencies"), so it is built here rather than by
1236 # goModule, which gives every package version "0" and no vendored
1237 # modules. Its version is the CLI's, stamped into the binary, and its
1238 # vendored modules are one fixed-output derivation, klaus-go-modules,
1239 # resolved from the whole module with its tests, so the checks in
1240 # nix/checks/flow.nix build over the same modules as the package. The
1241 # package's source holds no test and no prose, and it runs no tests: the
1242 # checks do. It runs git, tmux, nix and the agent CLIs it launches from
1243 # the user's PATH; none of them is a dependency of the package.
1244 # bin/valley-flow is a symlink to bin/klaus: the one binary names itself
1245 # by the name it runs under, and `valley flow` runs valley-flow from PATH.
1246 flowComplete = lib.fileset.toSource {
1247 root = ../.;
1248 fileset = lib.fileset.difference ../flow unread;
1249 };
1250 valley-flow = pkgs.buildGoModule {
1251 pname = "valley-flow";
1252 inherit version;
1253 src = lib.fileset.toSource {
1254 root = ../.;
1255 fileset = lib.fileset.difference ../flow (
1256 lib.fileset.unions [
1257 unread
1258 goTests
1259 ../flow/e2e
1260 ]
1261 );
1262 };
1263 modRoot = "flow";
1264 subPackages = [ "cmd/klaus" ];
1265 env = noCgoOnDarwin;
1266 vendorHash = "sha256-vh51S12HVVFjHr0DSLZlvBFLWarOlFN7vxXApVb69Dk=";
1267 # Named without the version, which changes with every commit, and read
1268 # from the whole module, so test-only imports are vendored too.
1269 overrideModAttrs = _: _: {
1270 name = "klaus-go-modules";
1271 src = flowComplete;
1272 };
1273 ldflags = [ "-X the-valley/flow/internal/cmd.version=${version}" ];
1274 doCheck = false;
1275 postInstall = ''
1276 ln -s klaus $out/bin/valley-flow
1277 '';
1278 meta.mainProgram = "valley-flow";
1279 };
1280
1281 # klaus is valley-flow's program in the package an installed self-update
1282 # builds, installs and smoke-tests by default (flow/internal/selfupdate):
1283 # the attribute packages.<system>.klaus, a store path named
1284 # klaus-<version>, which nix profile installs as the element klaus, and
1285 # bin/klaus, its mainProgram. It holds symlinks to valley-flow's two
1286 # executables, so the program is compiled once, and an executable keeps
1287 # the name it is run by, which the program names itself after.
1288 klaus =
1289 pkgs.runCommandLocal "klaus-${version}"
1290 {
1291 meta.mainProgram = "klaus";
1292 }
1293 ''
1294 mkdir -p $out/bin
1295 ln -s ${valley-flow}/bin/klaus ${valley-flow}/bin/valley-flow $out/bin/
1296 '';
1297}