diff --git a/flake.nix b/flake.nix index 4bdd245..351e0b4 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,7 @@ makeWrapper ${qs}/bin/quickshell $out/bin/nova-shell \ --add-flags "-p ${nova-shell}/share/nova-shell/shell.qml" ''; + docs = pkgs.callPackage ./nix/docs.nix { inherit self; }; default = nova-shell; } ); @@ -93,6 +94,7 @@ formatting = treefmt-eval.config.build.check self; build = self.packages.${pkgs.stdenv.hostPlatform.system}.default; 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: { pname = "nova-stats-clippy"; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.clippy ]; diff --git a/nix/docs.nix b/nix/docs.nix new file mode 100644 index 0000000..9779c2b --- /dev/null +++ b/nix/docs.nix @@ -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' + + + + + + nova-shell options + + + +

nova-shell options

+

Auto-generated from the home-manager module declarations.

+ HEADER + + ${lib.getExe pkgs.pandoc} -f markdown -t html ${optionsDoc.optionsCommonMark} >> $out/index.html + + cat >> $out/index.html <<'FOOTER' + + + FOOTER +''