From 04b7ba3a33bded61429bf18f0513983c5ab08eb3 Mon Sep 17 00:00:00 2001 From: pennae Date: Sun, 1 Oct 2023 18:41:26 +0200 Subject: add *some* documentation --- doc/default.nix | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 doc/default.nix (limited to 'doc/default.nix') diff --git a/doc/default.nix b/doc/default.nix new file mode 100644 index 0000000..95b9dea --- /dev/null +++ b/doc/default.nix @@ -0,0 +1,47 @@ +{ pkgs ? import { config = {}; overlays = []; } +}: + +let + evaluated = pkgs.lib.evalModules { + modules = [ + ../openwrt + ]; + specialArgs = { + inherit pkgs; + }; + }; + + optionsDoc = pkgs.nixosOptionsDoc { + inherit (evaluated) options; + transformOptions = opt: + let + cwd = toString ../.; + shorten = decl: + let + removed = pkgs.lib.removePrefix cwd decl; + in + if removed != decl + then { + url = + "https://git.eno.space/dewclaw.git/tree${removed}" + + (if pkgs.lib.hasSuffix ".nix" removed + then "" + else "/default.nix"); + name = ""; + } + else removed; + in + opt // { declarations = map shorten opt.declarations; }; + }; +in + +pkgs.runCommand "dewclaw-book" { + src = ./src; + buildInputs = [ pkgs.mdbook ]; +} '' + cp -r --no-preserve=all $src ./src + ln -s ${optionsDoc.optionsCommonMark} ./src/options.md + ln -s ${../README.md} ./src/README.md + mdbook build + mv book $out +'' -- cgit v1.2.3