config/profiles/web/docs/default.nix

49 lines
1.7 KiB
Nix

{ config, pkgs, lib, mkDomain, ... }:
{
options = with lib; {
#services.docs-to-host.enable = mkEnable "docs-to-host";
services.docs-to-host.docs = mkOption {
type = types.listOf (types.submodule {
options = {
subdir = mkOption {
type = types.str;
example = "pdoc";
description = lib.mdDoc "The path at which the documentation will be linked";
};
path = mkOption {
type = types.path;
example = lib.literalExpression "pkgs.fetchzip {...}";
description = lib.mdDoc "The static html documentation to host";
};
desc = mkOption {
type = types.str;
#description = "A short decription about the hosted documentation in markdown.";
description = "A short decription about the hosted documentation.";
};
};
});
default = [ ];
#description = lib.mdDoc ''TODO'';
};
};
config = let
cfg = config.services.docs-to-host;
mkRow = {subdir, path, desc}: ''<tr><td><a href="${subdir}/">${subdir}/</a><td>${desc}'';
mkEntry = {subdir, path, desc}: { name = subdir; path = path; };
in {
services.nginx.virtualHosts.${mkDomain "docs"} = {
forceSSL = true; # addSSL = true;
enableACME = true; #useACMEHost = acmeDomain;
root = pkgs.linkFarm "docs-html" ([{name = "index.html"; path = pkgs.writeText "docs-index.html" ''
<!DOCTYPE html>
<table>
<tr><th>URL<th>Desc
${lib.concatStringsSep "\n" ( builtins.map mkRow cfg.docs ) }
</table>
'';
}] ++ (builtins.map mkEntry cfg.docs));
};
};
}