gunk-dev/the-valley

knowledge-lint.nix

sourcec54965c690dfmain's published tip history
1.0 KiB
1# The knowledge lint as a derivation over one project tree: frontmatter vetted
2# against schema/node.cue, filename coherence, and reference integrity
3# (ida-1ec03b1). The tree is an argument, so the same derivation checks this
4# repo's graph and any other project's.
5#
6# The lint itself is a Python script rather than Nix: it walks markdown and
7# resolves paths, and Nix is the wrong language for both. Nix supplies the tree
8# and the toolchain and nothing else.
9#
10# Instantiate through the flake's `lib.knowledgeLint` rather than importing this
11# file directly — that entry point is what a consuming project gets from a flake
12# input, and it pins the toolchain and the schema for it.
13{
14 pkgs,
15 src,
16 root ? ".the-valley",
17 name ? "knowledge-lint",
18}:
19
20pkgs.runCommand name
21 {
22 nativeBuildInputs = [
23 pkgs.cue
24 pkgs.python3
25 ];
26 }
27 ''
28 mkdir -p work
29 python3 ${./knowledge-lint.py} \
30 --tree ${src} \
31 --root "${root}" \
32 --schema ${../schema/node.cue} \
33 --work work
34 touch $out
35 ''