gunk-dev/the-valley

knowledge.nix

source149740feef72main's published tip history
2.5 KiB
1# The knowledge lint and the prose: the lint in the reusable form a consuming
2# project instantiates, the graphs it must reject, and the format every
3# markdown file is held to. the-valley's own source holds no knowledge graph:
4# its plan graph is project storage, at refs/the-valley/knots, and the push
5# hook holds it to the knot module's rules. The nodes under
6# archive/.the-valley/ are history, and nothing lints them.
7{
8 pkgs,
9 self,
10 system,
11 packages,
12 ...
13}:
14{
15 # The lint over the consumer graph, under the name main's policy still
16 # requires. A change's required checks come from its target's policy,
17 # and the policy on main declares knowledge-lint, so a change to main
18 # needs this attribute until that policy stops declaring it.
19 knowledge-lint = self.lib.knowledgeLint {
20 inherit system;
21 src = ../../examples/graphs/consumer;
22 };
23
24 # The reusable form, exercised over a foreign tree: a project that
25 # is a README, a docs directory and seven nodes, and a project with no
26 # graph at all. Both must pass, and both are checked by depending on
27 # the instantiated derivations rather than by re-running the lint.
28 knowledge-lint-consumer = pkgs.runCommand "valley-knowledge-lint-consumer" {
29 consumer = self.lib.knowledgeLint {
30 inherit system;
31 src = ../../examples/graphs/consumer;
32 };
33 graphless = self.lib.knowledgeLint {
34 inherit system;
35 src = ../../examples/graphs/graphless;
36 };
37 } (builtins.readFile ./knowledge-lint-consumer.sh);
38
39 # The lint must fail on a broken graph, and its failure must name
40 # the file and the defect — a check that only says "no" leaves the
41 # reader to find the breakage themselves. The script and the schema
42 # here are the same store paths lib.knowledgeLint uses, so the
43 # rejections cannot drift from what a consumer runs.
44 knowledge-lint-rejects = pkgs.runCommand "valley-knowledge-lint-rejects" {
45 nativeBuildInputs = [
46 pkgs.cue
47 pkgs.python3
48 ];
49 lint = ../knowledge-lint.py;
50 nodeSchema = ../../schema/node.cue;
51 graphs = ../../examples/graphs;
52 rejectedCases = ./knowledge-lint-rejected.txt;
53 } (builtins.readFile ./knowledge-lint-rejects.sh);
54
55 # Markdown prose format (ida-1ec03b1): the check is formatter
56 # idempotence — formatting the tree must change nothing. On failure,
57 # fix with `nix run .#fmt`.
58 prose-format = pkgs.runCommand "valley-prose-format" {
59 nativeBuildInputs = [ pkgs.prettier ];
60 tree = self;
61 inherit (packages) proseFmtArgs;
62 } (builtins.readFile ./prose-format.sh);
63}