gunk-dev/the-valley

cli.nix

source0a94c1215767main's published tip history
4.4 KiB
1# bin/valley: that it stays a lint-clean script, what its review verb
2# anchors a note to, what its deriver makes of a policy and a diff, and
3# what its review verb publishes when it files an integration request.
4{ pkgs, packages, ... }:
5{
6 # The CLI must stay a lint-clean script whose help verb answers
7 # without a repo or a remote — the cheap end of its eviction clause
8 # (dcr-74c3158); anything needing more graduates instead. The
9 # completions are held to the same bar, and the installed package
10 # must carry them at the auto-linked paths.
11 valley-cli = pkgs.runCommand "valley-cli" {
12 nativeBuildInputs = [
13 pkgs.shellcheck
14 pkgs.zsh
15 packages.valley
16 ];
17 cliScript = ../../bin/valley;
18 bashCompletion = ../../completions/valley.bash;
19 zshCompletion = ../../completions/_valley;
20 valley = packages.valley;
21 } (builtins.readFile ./valley-cli.sh);
22
23 # review's notes: the anchors are the whole claim, so they are
24 # pinned here rather than left to the reader of bin/valley. The
25 # session is real — a pty, real less, a pager filter that
26 # restructures the diff, and an $EDITOR that inserts lines while
27 # the pager is open — because every property under test is a
28 # property of that arrangement: that v is handed the raw buffer
29 # and not the rendering, that an inserted line becomes a note,
30 # and that the file and line it names are the ones it sat on.
31 review-notes = pkgs.runCommand "valley-review-notes" {
32 nativeBuildInputs = [
33 pkgs.git
34 pkgs.less
35 pkgs.util-linux # script(1), for the pty less insists on
36 packages.valley-script
37 ];
38 # The reviewer, as a script: four insertions and one edit of a
39 # line that was already there. The edit is deliberately far
40 # from every insertion, since -U0 would otherwise merge them
41 # into one hunk and the note would be dropped with it.
42 reviewer = pkgs.writeShellScript "valley-review-notes-editor" (
43 builtins.readFile ./review-notes-editor.sh
44 );
45 } (builtins.readFile ./review-notes.sh);
46
47 # The verification-policy deriver (dcr-f41f718). Composing the two
48 # layers is CUE's job and is pinned by cue-vet; matching paths is
49 # the script's own, and a path matcher is wrong exactly at the glob
50 # boundaries — `*` inside one segment against `**` across segments,
51 # `**` matching no segment at all — and at the sides of a diff a
52 # naive reader drops: a rename's old path and a deletion. Each is
53 # pinned by driving the real script over a scratch repository and
54 # the scratch policy in examples/policy/deriver/, whose floor is
55 # one glob boundary per class. A check's cost is pinned the same way:
56 # marking a check slow moves it between the summary lines and the
57 # --cost lists, and changes nothing owed.
58 policy-deriver = pkgs.runCommand "valley-policy-deriver" {
59 nativeBuildInputs = [
60 pkgs.git
61 pkgs.cue
62 packages.valley-script
63 ];
64 fixtures = ../../examples/policy/deriver;
65 schema = ../../schema/verification.cue;
66 } (builtins.readFile ./policy-deriver.sh);
67
68 # review's [a]sk, driven end to end over scratch repositories: a branch
69 # reviewed, the request filed, and what the receiving side then holds.
70 # The claim is about sequencing, so it is only observable from there —
71 # the bare repo logs every push it receives, and the check reads that
72 # log to see that ONE of them carried the evidence and the request
73 # together. Every check the scratch policy declares uses the command
74 # runner, for the reason attest-e2e gives: a nix build has no daemon.
75 # The packaged CLI carries its own schema, so the scratch projects that
76 # stand for projects other than the-valley carry no schema/. cliScript is
77 # bin/valley itself, for its other shipping mode: run straight from a
78 # the-valley checkout, it reads the schema there.
79 valley-request = pkgs.runCommand "valley-request" {
80 nativeBuildInputs = [
81 pkgs.git
82 pkgs.cue
83 pkgs.openssh
84 packages.attest
85 packages.valley-script
86 ];
87 schemaFile = ../../schema/verification.cue;
88 cliScript = ../../bin/valley;
89 } (builtins.readFile ./valley-request.sh);
90
91 # Read origin's request/outcome refs and distinguish a pending request,
92 # a recorded decision and a landing, without moving the user's checkout.
93 valley-status = pkgs.runCommand "valley-status" {
94 nativeBuildInputs = [
95 pkgs.git
96 packages.valley-script
97 ];
98 } (builtins.readFile ./valley-status.sh);
99}