add auto-generated docs from hm-module options

This commit is contained in:
Damocles 2026-04-17 19:42:39 +02:00
parent b5b1f4f406
commit 715c20aa65
2 changed files with 101 additions and 0 deletions

View file

@ -67,6 +67,7 @@
makeWrapper ${qs}/bin/quickshell $out/bin/nova-shell \ makeWrapper ${qs}/bin/quickshell $out/bin/nova-shell \
--add-flags "-p ${nova-shell}/share/nova-shell/shell.qml" --add-flags "-p ${nova-shell}/share/nova-shell/shell.qml"
''; '';
docs = pkgs.callPackage ./nix/docs.nix { inherit self; };
default = nova-shell; default = nova-shell;
} }
); );
@ -93,6 +94,7 @@
formatting = treefmt-eval.config.build.check self; formatting = treefmt-eval.config.build.check self;
build = self.packages.${pkgs.stdenv.hostPlatform.system}.default; build = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
nova-stats = self.packages.${pkgs.stdenv.hostPlatform.system}.nova-stats; nova-stats = self.packages.${pkgs.stdenv.hostPlatform.system}.nova-stats;
docs = self.packages.${pkgs.stdenv.hostPlatform.system}.docs;
nova-stats-clippy = (pkgs.callPackage ./nix/stats-daemon.nix { }).overrideAttrs (old: { nova-stats-clippy = (pkgs.callPackage ./nix/stats-daemon.nix { }).overrideAttrs (old: {
pname = "nova-stats-clippy"; pname = "nova-stats-clippy";
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.clippy ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.clippy ];

99
nix/docs.nix Normal file
View 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
''