gunk-dev/the-valley

knowledge.nix

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