gunk-dev/the-valley

cli.nix

source813c6679e1c2main's published tip history
4.2 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.
56 policy-deriver = pkgs.runCommand "valley-policy-deriver" {
57 nativeBuildInputs = [
58 pkgs.git
59 pkgs.cue
60 packages.valley-script
61 ];
62 fixtures = ../../examples/policy/deriver;
63 schema = ../../schema/verification.cue;
64 } (builtins.readFile ./policy-deriver.sh);
65
66 # review's [a]sk, driven end to end over scratch repositories: a branch
67 # reviewed, the request filed, and what the receiving side then holds.
68 # The claim is about sequencing, so it is only observable from there —
69 # the bare repo logs every push it receives, and the check reads that
70 # log to see that ONE of them carried the evidence and the request
71 # together. Every check the scratch policy declares uses the command
72 # runner, for the reason attest-e2e gives: a nix build has no daemon.
73 # The packaged CLI carries its own schema, so the scratch projects that
74 # stand for projects other than the-valley carry no schema/. cliScript is
75 # bin/valley itself, for its other shipping mode: run straight from a
76 # the-valley checkout, it reads the schema there.
77 valley-request = pkgs.runCommand "valley-request" {
78 nativeBuildInputs = [
79 pkgs.git
80 pkgs.cue
81 pkgs.openssh
82 packages.attest
83 packages.valley-script
84 ];
85 schemaFile = ../../schema/verification.cue;
86 cliScript = ../../bin/valley;
87 } (builtins.readFile ./valley-request.sh);
88
89 # Read origin's request/outcome refs and distinguish a pending request,
90 # a recorded decision and a landing, without moving the user's checkout.
91 valley-status = pkgs.runCommand "valley-status" {
92 nativeBuildInputs = [
93 pkgs.git
94 packages.valley-script
95 ];
96 } (builtins.readFile ./valley-status.sh);
97}