diff options
Diffstat (limited to 'doc/default.nix')
-rw-r--r-- | doc/default.nix | 47 |
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 +'' |