summaryrefslogtreecommitdiff
path: root/doc/default.nix
diff options
context:
space:
mode:
authorpennae <pennae.git@eno.space>2023-10-01 18:41:26 +0200
committerpennae <pennae.git@eno.space>2023-10-01 18:41:26 +0200
commit04b7ba3a33bded61429bf18f0513983c5ab08eb3 (patch)
tree901217fc3f454d4a79053074536d192728519fd2 /doc/default.nix
parent61e20312ff66ab8d9af6ed2963ffc3acca50b14e (diff)
downloaddewclaw-04b7ba3a33bded61429bf18f0513983c5ab08eb3.tar.gz
dewclaw-04b7ba3a33bded61429bf18f0513983c5ab08eb3.tar.xz
dewclaw-04b7ba3a33bded61429bf18f0513983c5ab08eb3.zip
add *some* documentation
Diffstat (limited to 'doc/default.nix')
-rw-r--r--doc/default.nix47
1 files changed, 47 insertions, 0 deletions
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 <nixpkgs> { 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 = "<dewclaw${removed}>";
+ }
+ 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
+''