add auto-generated docs from hm-module options
This commit is contained in:
parent
b5b1f4f406
commit
715c20aa65
2 changed files with 101 additions and 0 deletions
99
nix/docs.nix
Normal file
99
nix/docs.nix
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
{
|
||||
pkgs,
|
||||
lib ? pkgs.lib,
|
||||
self,
|
||||
}:
|
||||
let
|
||||
# Evaluate the hm-module with a minimal mock config so nixosOptionsDoc
|
||||
# can introspect the option declarations without a real home-manager eval.
|
||||
evaledModules = lib.evalModules {
|
||||
modules = [
|
||||
(import ./hm-module.nix self)
|
||||
{
|
||||
# Stub the home-manager / nixpkgs options the module touches
|
||||
options = {
|
||||
home.packages = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.package;
|
||||
default = [ ];
|
||||
};
|
||||
xdg.configFile = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.anything;
|
||||
default = { };
|
||||
};
|
||||
programs.niri.settings.layer-rules = lib.mkOption {
|
||||
type = lib.types.anything;
|
||||
default = [ ];
|
||||
};
|
||||
services.poweralertd.enable = lib.mkOption {
|
||||
type = lib.types.anything;
|
||||
default = false;
|
||||
};
|
||||
systemd.user.services = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.anything;
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
config._module.args = {
|
||||
inherit pkgs;
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
optionsDoc = pkgs.nixosOptionsDoc {
|
||||
options = {
|
||||
programs.nova-shell = evaledModules.options.programs.nova-shell;
|
||||
};
|
||||
documentType = "none";
|
||||
warningsAreErrors = false;
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "nova-shell-docs" { } ''
|
||||
mkdir -p $out
|
||||
cp ${optionsDoc.optionsCommonMark} $out/options.md
|
||||
|
||||
cat > $out/index.html <<'HEADER'
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>nova-shell options</title>
|
||||
<style>
|
||||
:root { color-scheme: dark; }
|
||||
body {
|
||||
font-family: system-ui, sans-serif;
|
||||
max-width: 52rem;
|
||||
margin: 2rem auto;
|
||||
padding: 0 1rem;
|
||||
background: #1e1e2e;
|
||||
color: #cdd6f4;
|
||||
}
|
||||
h1 { color: #cba6f7; }
|
||||
h2 { color: #89b4fa; border-bottom: 1px solid #313244; padding-bottom: .3rem; }
|
||||
code, pre {
|
||||
background: #181825;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
code { padding: .15em .3em; }
|
||||
pre { padding: 1em; overflow-x: auto; }
|
||||
dt { font-weight: bold; color: #f5c2e7; margin-top: 1.5em; font-family: monospace; }
|
||||
dd { margin-left: 1.5em; }
|
||||
a { color: #89dceb; }
|
||||
.type { color: #a6e3a1; }
|
||||
.default { color: #fab387; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>nova-shell options</h1>
|
||||
<p>Auto-generated from the home-manager module declarations.</p>
|
||||
HEADER
|
||||
|
||||
${lib.getExe pkgs.pandoc} -f markdown -t html ${optionsDoc.optionsCommonMark} >> $out/index.html
|
||||
|
||||
cat >> $out/index.html <<'FOOTER'
|
||||
</body>
|
||||
</html>
|
||||
FOOTER
|
||||
''
|
||||
Loading…
Add table
Add a link
Reference in a new issue