Files
clan-core/docs/nix/default.nix
2025-10-08 13:01:26 +02:00

75 lines
1.7 KiB
Nix

{
pkgs,
module-docs,
clan-cli-docs,
clan-lib-openapi,
roboto,
fira-code,
docs-options,
...
}:
let
uml-c4 = pkgs.python3Packages.plantuml-markdown.override { plantuml = pkgs.plantuml-c4; };
in
pkgs.stdenv.mkDerivation {
name = "clan-documentation";
# Points to repository root.
# so that we can access directories outside of docs to include code snippets
src = pkgs.lib.fileset.toSource {
root = ../..;
fileset = pkgs.lib.fileset.unions [
# Docs directory
../../docs
# Icons needed for the build
../../pkgs/clan-app/ui/icons
# Any other directories that might be referenced for code snippets
# Add them here as needed based on what mkdocs actually uses
];
};
nativeBuildInputs = [
pkgs.python3
uml-c4
]
++ (with pkgs.python3Packages; [
mkdocs
mkdocs-material
mkdocs-redoc-tag
mkdocs-redirects
]);
configurePhase = ''
pushd docs
mkdir -p ./site/reference/cli
cp -af ${module-docs}/services/* ./site/services/
cp -af ${module-docs}/reference/* ./site/reference/
cp -af ${clan-cli-docs}/* ./site/reference/cli/
cp -af ${clan-lib-openapi} ./site/openapi.json
chmod -R +w ./site
echo "Generated API documentation in './site/reference/' "
rm -rf ./site/options
cp -r ${docs-options} ./site/options
chmod -R +w ./site/options
# Link to fonts
ln -snf ${roboto}/share/fonts/truetype/Roboto-Regular.ttf ./site/static/
ln -snf ${fira-code}/share/fonts/truetype/FiraCode-VF.ttf ./site/static/
# Copy icons into place
cp -af ../pkgs/clan-app/ui/icons ./site/static/
'';
buildPhase = ''
mkdocs build --strict
ls -la .
'';
installPhase = ''
cp -a out/ $out/
'';
}