gunk-dev/the-valley

knowledge.nix

source61db20b2e4bfmain's published tip history
2.3 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 reusable form, exercised over a foreign tree: a project that
16 # is a README, a docs directory and seven nodes, and a project with no
17 # graph at all. Both must pass, and both are checked by depending on
18 # the instantiated derivations rather than by re-running the lint.
19 knowledge-lint-consumer = pkgs.runCommand "valley-knowledge-lint-consumer" {
20 consumer = self.lib.knowledgeLint {
21 inherit system;
22 src = ../../examples/graphs/consumer;
23 };
24 graphless = self.lib.knowledgeLint {
25 inherit system;
26 src = ../../examples/graphs/graphless;
27 };
28 } (builtins.readFile ./knowledge-lint-consumer.sh);
29
30 # The lint must fail on a broken graph, and its failure must name
31 # the file and the defect โ€” a check that only says "no" leaves the
32 # reader to find the breakage themselves. The script and the schema
33 # here are the same store paths lib.knowledgeLint uses, so the
34 # rejections cannot drift from what a consumer runs.
35 knowledge-lint-rejects = pkgs.runCommand "valley-knowledge-lint-rejects" {
36 nativeBuildInputs = [
37 pkgs.cue
38 pkgs.python3
39 ];
40 lint = ../knowledge-lint.py;
41 nodeSchema = ../../schema/node.cue;
42 graphs = ../../examples/graphs;
43 rejectedCases = ./knowledge-lint-rejected.txt;
44 } (builtins.readFile ./knowledge-lint-rejects.sh);
45
46 # Markdown prose format (ida-1ec03b1): formatter idempotence โ€”
47 # formatting the tree must change nothing โ€” and, across README.md,
48 # AGENTS.md and docs/*.md, relative link and heading-anchor integrity
49 # and the style rules of AGENTS.md that a pattern can catch.
50 # On formatting failure, fix with `nix run .#fmt`.
51 prose-format = pkgs.runCommand "valley-prose-format" {
52 nativeBuildInputs = [
53 pkgs.gawk
54 pkgs.prettier
55 pkgs.python3
56 ];
57 tree = self;
58 inherit (packages) proseFmtArgs;
59 } (builtins.readFile ./prose-format.sh);
60}