gunk-dev/the-valley

knowledge.nix

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