{ inputs, self, ... }: { perSystem = { config, self', inputs', pkgs, lib, ... }: { /* Check the links, including anchors (not currently supported by mdbook) Putting this in a separate check has the benefits that - output can always be inspect with browser - this slow check (1 minute) is not part of the iteration cycle Ideally https://github.com/linkchecker/linkchecker/pull/661 is merged upstream, so that it's quick and can run often without blocking the iteration cycle unnecessarily. */ # checks.linkcheck = # pkgs.runCommand "linkcheck" # { # nativeBuildInputs = [pkgs.linkchecker pkgs.python3]; # site = config.packages.website; # } '' # # https://linkchecker.github.io/linkchecker/man/linkcheckerrc.html # cat >>$TMPDIR/linkcheckrc < $out cat ${highlight-nix} >> $out ''; highlight-style = pkgs.fetchurl { url = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/vs.min.css"; hash = "sha256-E1kfafj5iO+Tw/04hxdSG+OnvczojOXK2K0iCEYfzSw="; }; website = pkgs.stdenvNoCC.mkDerivation { name = "website"; nativeBuildInputs = [pkgs.mdbook pkgs.mdbook-linkcheck]; src = ./.; buildPhase = '' runHook preBuild rm ./src/intro.md cp ${self + /README.md} ./src/intro.md # insert highlight.js cp ${self'.packages.highlight-js} ./src/highlight.js cp ${self'.packages.highlight-style} ./src/highlight.css # insert the generated part of the summary into the origin SUMMARY.md cp ./src/SUMMARY.md SUMMARY.md.orig { while read ln; do case "$ln" in "# Modules Reference") echo "# Modules Reference" cat ${self'.packages.generated-summary-md} ;; *) echo "$ln" ;; esac done } < SUMMARY.md.orig > src/SUMMARY.md mkdir -p ./theme cp ${self + /modules/dream2nix/core/docs/theme/favicon.png} ./theme/favicon.png mkdir -p src/options for f in ${config.packages.generated-docs}/*.html; do cp "$f" "src/options/$(basename "$f" .html).md" done mdbook build --dest-dir $TMPDIR/out cp -r $TMPDIR/out/html $out cp _redirects $out # TODO: point to something else than public.html echo 'to the options' \ >$out/options.html runHook postBuild ''; dontInstall = true; }; }; }; }