75 lines
2.2 KiB
Nix
75 lines
2.2 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
|
ndg.url = "github:feel-co/ndg";
|
|
};
|
|
|
|
# graciously lifted from nixos + hjem-rum doc gen routines
|
|
outputs =
|
|
inputs: with inputs; {
|
|
lib.pak-chooie =
|
|
{
|
|
pkgs,
|
|
lib,
|
|
projectName ? "unf",
|
|
basePath ? /home/me/myproject,
|
|
newPath ? "https://my.site/unf/docs" modules,
|
|
specialArgs ? { },
|
|
modules ? [ ],
|
|
}:
|
|
let
|
|
eval = lib.evalModules {
|
|
specialArgs = {
|
|
inherit pkgs;
|
|
} // specialArgs;
|
|
modules = [
|
|
(
|
|
{ lib, ... }:
|
|
{
|
|
options._module.args = lib.mkOption {
|
|
internal = true;
|
|
};
|
|
}
|
|
)
|
|
] ++ modules;
|
|
};
|
|
optionsDoc = pkgs.nixosOptionsDoc {
|
|
inherit (eval) options;
|
|
|
|
transformOptions =
|
|
opt:
|
|
opt
|
|
// {
|
|
# Clean up declaration sites to not refer to the NixOS source tree.
|
|
declarations =
|
|
let
|
|
devDir = toString basePath;
|
|
inherit (lib) hasPrefix removePrefix;
|
|
in
|
|
map (
|
|
decl:
|
|
if hasPrefix (toString devDir) (toString decl) then
|
|
let
|
|
subpath = removePrefix "/" (removePrefix (toString devDir) (toString decl));
|
|
in
|
|
{
|
|
url = "${newpath}${subpath}";
|
|
name = subpath;
|
|
}
|
|
else
|
|
decl
|
|
) opt.declarations;
|
|
};
|
|
};
|
|
in
|
|
pkgs.runCommandLocal "${projectName}-docs"
|
|
{ nativeBuildInputs = [ ndg.packages.${pkgs.system}.ndg ]; }
|
|
''
|
|
ndg --verbose html --jobs $NIX_BUILD_CORES --title "${projectName}" \
|
|
--module-options "${optionsDoc.optionsJSON}/share/doc/nixos/options.json" \
|
|
--generate-search true \
|
|
--output-dir "$out"
|
|
'';
|
|
};
|
|
}
|