gunk-dev/the-valley

knowledge.nix

source2886163c0514main's published tip history
2.1 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): the check is formatter
47 # idempotence — formatting the tree must change nothing. On failure,
48 # fix with `nix run .#fmt`.
49 prose-format = pkgs.runCommand "valley-prose-format" {
50 nativeBuildInputs = [ pkgs.prettier ];
51 tree = self;
52 inherit (packages) proseFmtArgs;
53 } (builtins.readFile ./prose-format.sh);
54}