docs: Add a section on module specific options (#1355)

This commit only adds Home-Manager specific options, we should add
sections for the different kind of modules too.

This is _not_ added to the man docs, as it is more complex. If need
arises we could look into how to do it.
This commit is contained in:
traxys 2024-03-30 14:52:32 +01:00 committed by GitHub
parent c706207007
commit 6d1ef5864b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 37 additions and 8 deletions

View file

@ -69,6 +69,16 @@
}) })
] ]
++ (rawModules pkgsDoc); ++ (rawModules pkgsDoc);
hmOptions =
builtins.removeAttrs
(lib.evalModules {
modules = [
(import ../wrappers/modules/hm.nix {inherit lib;})
];
})
.options
["_module"];
in in
rec { rec {
options-json = options-json =
@ -93,6 +103,6 @@ in
docs = pkgsDoc.callPackage ./mdbook { docs = pkgsDoc.callPackage ./mdbook {
inherit transformOptions; inherit transformOptions;
modules = topLevelModules; modules = topLevelModules;
inherit helpers; inherit helpers hmOptions;
}; };
} }

View file

@ -7,6 +7,10 @@
- [Extending a standalone configuration](./user-guide/extending-config.md) - [Extending a standalone configuration](./user-guide/extending-config.md)
- [FAQ](./user-guide/faq.md) - [FAQ](./user-guide/faq.md)
# Module Specific Options
- [Home Manager Usage](./modules/hm.md)
# Options # Options
@NIXVIM_OPTIONS@ @NIXVIM_OPTIONS@

View file

@ -5,6 +5,7 @@
helpers, helpers,
nixosOptionsDoc, nixosOptionsDoc,
transformOptions, transformOptions,
hmOptions,
}: }:
with lib; let with lib; let
options = lib.evalModules { options = lib.evalModules {
@ -246,6 +247,7 @@ with lib; let
cp -r --no-preserve=all $inputs/* ./ cp -r --no-preserve=all $inputs/* ./
cp ${../../CONTRIBUTING.md} ./CONTRIBUTING.md cp ${../../CONTRIBUTING.md} ./CONTRIBUTING.md
cp -r ${../user-guide} ./user-guide cp -r ${../user-guide} ./user-guide
cp -r ${../modules} ./modules
# Copy the generated MD docs into the build directory # Copy the generated MD docs into the build directory
# Using pkgs.writeShellScript helps to avoid the "bash: argument list too long" error # Using pkgs.writeShellScript helps to avoid the "bash: argument list too long" error
@ -254,7 +256,10 @@ with lib; let
# Prepare SUMMARY.md for mdBook # Prepare SUMMARY.md for mdBook
# Using pkgs.writeText helps to avoid the same error as above # Using pkgs.writeText helps to avoid the same error as above
substituteInPlace ./SUMMARY.md \ substituteInPlace ./SUMMARY.md \
--replace "@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/hm.md \
--replace-fail "@HM_OPTIONS@" "$(cat ${mkMDDoc hmOptions})"
''; '';
in in
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {

6
docs/modules/hm.md Normal file
View file

@ -0,0 +1,6 @@
# Home Manager Usage
All nixvim options are available at `programs.nixvim.*` when nixvim is used in home-manager.
There are a few home-manager specific options that are documented here.
@HM_OPTIONS@

View file

@ -29,12 +29,9 @@ in {
}; };
modules = modules =
[ [
{ (import ./modules/hm.nix {
options = { inherit lib;
enable = mkEnableOption "nixvim"; })
defaultEditor = mkEnableOption "nixvim as the default editor";
};
}
] ]
++ shared.topLevelModules; ++ shared.topLevelModules;
}; };

7
wrappers/modules/hm.nix Normal file
View file

@ -0,0 +1,7 @@
{lib}:
with lib; {
options = {
enable = mkEnableOption "nixvim";
defaultEditor = mkEnableOption "nixvim as the default editor";
};
}