From 798d445f3e1828d792c75ef4bcec6378b16a3474 Mon Sep 17 00:00:00 2001 From: DavHau Date: Fri, 8 Aug 2025 13:15:33 +0700 Subject: [PATCH] docs: move options search to separate page --- docs/.gitignore | 2 +- docs/mkdocs.yml | 5 ++-- docs/nix/default.nix | 6 ++-- docs/nix/options/flake-module.nix | 49 +++++++++++++++++++++++++++++-- docs/site/guides/flake-parts.md | 2 +- docs/site/options.md | 6 ---- docs/site/reference/index.md | 2 +- 7 files changed, 55 insertions(+), 17 deletions(-) delete mode 100644 docs/site/options.md diff --git a/docs/.gitignore b/docs/.gitignore index d79d037d4..5d02a552e 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -1,5 +1,5 @@ /site/reference /site/static -/site/options-page +/site/options /site/openapi.json !/site/static/extra.css diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index b07f00431..94e0593d4 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -6,7 +6,7 @@ edit_uri: _edit/main/docs/docs/ validation: omitted_files: warn - absolute_links: warn + absolute_links: ignore unrecognized_links: warn markdown_extensions: @@ -88,7 +88,7 @@ nav: - Templates: concepts/templates.md - Reference: - Overview: reference/index.md - - Clan Options: options.md + - Browse Options: "/options" - Services: - Overview: - reference/clanServices/index.md @@ -155,6 +155,7 @@ nav: - 05-deployment-parameters: decisions/05-deployment-parameters.md - Template: decisions/_template.md - Glossary: reference/glossary.md + - Browse Options: "/options" docs_dir: site site_dir: out diff --git a/docs/nix/default.nix b/docs/nix/default.nix index fb0483257..559ff0174 100644 --- a/docs/nix/default.nix +++ b/docs/nix/default.nix @@ -54,9 +54,9 @@ pkgs.stdenv.mkDerivation { chmod -R +w ./site/reference echo "Generated API documentation in './site/reference/' " - rm -r ./site/options-page || true - cp -r ${docs-options} ./site/options-page - chmod -R +w ./site/options-page + rm -rf ./site/options + cp -r ${docs-options} ./site/options + chmod -R +w ./site/options mkdir -p ./site/static/asciinema-player ln -snf ${asciinema-player-js} ./site/static/asciinema-player/asciinema-player.min.js diff --git a/docs/nix/options/flake-module.nix b/docs/nix/options/flake-module.nix index bd3718cad..a2f935e64 100644 --- a/docs/nix/options/flake-module.nix +++ b/docs/nix/options/flake-module.nix @@ -25,7 +25,7 @@ serviceModules = self.clan.modules; - baseHref = "/options-page/"; + baseHref = "/options/"; getRoles = module: @@ -126,7 +126,7 @@ nestedSettingsOption = mkOption { type = types.raw; description = '' - See [instances.${name}.roles.${roleName}.settings](${baseHref}?option_scope=0&option=instances.${name}.roles.${roleName}.settings) + See [instances.${name}.roles.${roleName}.settings](${baseHref}?option_scope=0&option=inventory.instances.${name}.roles.${roleName}.settings) ''; }; settingsOption = mkOption { @@ -161,6 +161,42 @@ } ]; + baseModule = + # Module + { config, ... }: + { + imports = (import (pkgs.path + "/nixos/modules/module-list.nix")); + nixpkgs.pkgs = pkgs; + clan.core.name = "dummy"; + system.stateVersion = config.system.nixos.release; + # Set this to work around a bug where `clan.core.settings.machine.name` + # is forced due to `networking.interfaces` being forced + # somewhere in the nixpkgs options + facter.detected.dhcp.enable = lib.mkForce false; + }; + + evalClanModules = + let + evaled = lib.evalModules { + class = "nixos"; + modules = [ + baseModule + { + clan.core.settings.directory = self; + } + self.nixosModules.clanCore + ]; + }; + in + evaled; + + coreOptions = + (pkgs.nixosOptionsDoc { + options = (evalClanModules.options).clan.core or { }; + warningsAreErrors = true; + transformOptions = self.clanLib.docs.stripStorePathsFromDeclarations; + }).optionsJSON; + in { # Uncomment for debugging @@ -175,10 +211,17 @@ # scopes = mapAttrsToList mkScope serviceModules; scopes = [ { - name = "Clan"; + inherit baseHref; + name = "Flake Options (clan.nix file)"; modules = docModules; urlPrefix = "https://git.clan.lol/clan/clan-core/src/branch/main/"; } + { + name = "Machine Options (clan.core NixOS options)"; + optionsJSON = "${coreOptions}/share/doc/nixos/options.json"; + urlPrefix = "https://git.clan.lol/clan/clan-core/src/branch/main/"; + + } ]; }; }; diff --git a/docs/site/guides/flake-parts.md b/docs/site/guides/flake-parts.md index 7bbb67d66..bdd1f6136 100644 --- a/docs/site/guides/flake-parts.md +++ b/docs/site/guides/flake-parts.md @@ -27,7 +27,7 @@ inputs = { ## Import the Clan flake-parts Module -After updating your flake inputs, the next step is to import the Clan flake-parts module. This will make the [Clan options](../options.md) available within `mkFlake`. +After updating your flake inputs, the next step is to import the Clan flake-parts module. This will make the [Clan options](/options) available within `mkFlake`. ```nix { diff --git a/docs/site/options.md b/docs/site/options.md deleted file mode 100644 index ee666e02d..000000000 --- a/docs/site/options.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -template: options.html ---- - - - diff --git a/docs/site/reference/index.md b/docs/site/reference/index.md index 82a440122..72a7d81a5 100644 --- a/docs/site/reference/index.md +++ b/docs/site/reference/index.md @@ -4,7 +4,7 @@ This section of the site provides an overview of available options and commands --- -- [Clan Configuration Option](../options.md) - for defining a Clan +- [Clan Configuration Option](/options) - for defining a Clan - Learn how to use the [Clan CLI](./cli/index.md) - Explore available [services](./clanServices/index.md) - [NixOS Configuration Options](./clan.core/index.md) - Additional options avilable on a NixOS machine.