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