wrappers: add meta.wrappers options to wrappers

Allows the docs to be a little less hard-coded.

Lays the groundwork for splitting up the platform-specific option docs
on a per-page basis.
This commit is contained in:
Matt Sturgeon 2024-10-22 10:03:37 +01:00
parent 574ae92a43
commit b076f006c6
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
6 changed files with 48 additions and 16 deletions

View file

@ -224,6 +224,35 @@ let
in in
"${padding}- [${name}](${path})" "${padding}- [${name}](${path})"
) docs.modules; ) docs.modules;
wrapperOptionFiles = lib.mapAttrs' (name: options: {
name = options.meta.wrapper.name.value;
# TODO:
# value.path = "./modules/${name}.md";
value.file = mkMDDoc options;
}) wrapperOptions;
wrapperOptionDocs =
pkgs.runCommandNoCCLocal "wrapper-option-doc"
{
__structuredAttrs = true;
files = lib.mapAttrs (name: value: value.file) mdbook.wrapperOptionFiles;
# TODO:
# paths = lib.mapAttrs (name: value: value.path) mdbook.wrapperOptionFiles;
}
''
for name in "''${!files[@]}"
do
# $file contains the docs built by mkMDDoc
file="''${files[$name]}"
# TODO: consider putting wrapper docs in separate files:
# path="''${paths[$name]}"
echo >> "$out"
echo "## $name" >> "$out"
echo >> "$out"
cat "$file" >> $out
done
'';
}; };
wrapperOptions = wrapperOptions =
@ -266,9 +295,7 @@ let
--replace-fail "@NIXVIM_OPTIONS@" "$(cat ${pkgs.writeText "nixvim-options-summary.md" mdbook.nixvimOptions})" --replace-fail "@NIXVIM_OPTIONS@" "$(cat ${pkgs.writeText "nixvim-options-summary.md" mdbook.nixvimOptions})"
substituteInPlace ./modules/wrapper-options.md \ substituteInPlace ./modules/wrapper-options.md \
--replace-fail "@NIXOS_OPTIONS@" "$(cat ${mkMDDoc wrapperOptions.nixos})" \ --replace-fail "@WRAPPER_OPTIONS@" "$(cat ${mdbook.wrapperOptionDocs})"
--replace-fail "@HM_OPTIONS@" "$(cat ${mkMDDoc wrapperOptions.hm})" \
--replace-fail "@DARWIN_OPTIONS@" "$(cat ${mkMDDoc wrapperOptions.darwin})"
''; '';
in in
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {

View file

@ -8,17 +8,5 @@ See [Standalone Usage](./standalone.md) for more info.
There are a few wrapper specific options that are documented below: There are a few wrapper specific options that are documented below:
## NixOS @WRAPPER_OPTIONS@
@NIXOS_OPTIONS@
## home-manager
@HM_OPTIONS@
## nix-darwin
@DARWIN_OPTIONS@
<!-- TODO: Add @STANDALONE_OPTIONS@ if we ever have standalone-specific options -->

View file

@ -1,3 +1,7 @@
{ {
imports = [ ./shared.nix ]; imports = [ ./shared.nix ];
config = {
meta.wrapper.name = "nix-darwin";
};
} }

View file

@ -17,5 +17,6 @@
config = { config = {
wrapRc = lib.mkOptionDefault false; wrapRc = lib.mkOptionDefault false;
impureRtp = lib.mkOptionDefault true; impureRtp = lib.mkOptionDefault true;
meta.wrapper.name = "home-manager";
}; };
} }

View file

@ -5,4 +5,8 @@
}; };
imports = [ ./shared.nix ]; imports = [ ./shared.nix ];
config = {
meta.wrapper.name = "NixOS";
};
} }

View file

@ -2,5 +2,13 @@
{ {
options = { options = {
enable = lib.mkEnableOption "nixvim"; enable = lib.mkEnableOption "nixvim";
meta.wrapper = {
name = lib.mkOption {
type = lib.types.str;
description = "The human-readable name of this nixvim wrapper. Used in documentation.";
internal = true;
};
};
}; };
} }