Skip to content

Commit

Permalink
docs: Add a section on module specific options (nix-community#1355)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
traxys authored Mar 30, 2024
1 parent c706207 commit 6d1ef58
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
12 changes: 11 additions & 1 deletion docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
})
]
++ (rawModules pkgsDoc);

hmOptions =
builtins.removeAttrs
(lib.evalModules {
modules = [
(import ../wrappers/modules/hm.nix {inherit lib;})
];
})
.options
["_module"];
in
rec {
options-json =
Expand All @@ -93,6 +103,6 @@ in
docs = pkgsDoc.callPackage ./mdbook {
inherit transformOptions;
modules = topLevelModules;
inherit helpers;
inherit helpers hmOptions;
};
}
4 changes: 4 additions & 0 deletions docs/mdbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- [Extending a standalone configuration](./user-guide/extending-config.md)
- [FAQ](./user-guide/faq.md)

# Module Specific Options

- [Home Manager Usage](./modules/hm.md)

# Options

@NIXVIM_OPTIONS@
Expand Down
7 changes: 6 additions & 1 deletion docs/mdbook/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
helpers,
nixosOptionsDoc,
transformOptions,
hmOptions,
}:
with lib; let
options = lib.evalModules {
Expand Down Expand Up @@ -246,6 +247,7 @@ with lib; let
cp -r --no-preserve=all $inputs/* ./
cp ${../../CONTRIBUTING.md} ./CONTRIBUTING.md
cp -r ${../user-guide} ./user-guide
cp -r ${../modules} ./modules
# Copy the generated MD docs into the build directory
# Using pkgs.writeShellScript helps to avoid the "bash: argument list too long" error
Expand All @@ -254,7 +256,10 @@ with lib; let
# Prepare SUMMARY.md for mdBook
# Using pkgs.writeText helps to avoid the same error as above
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
pkgs.stdenv.mkDerivation {
Expand Down
6 changes: 6 additions & 0 deletions docs/modules/hm.md
Original file line number Diff line number Diff line change
@@ -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@
9 changes: 3 additions & 6 deletions wrappers/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ in {
};
modules =
[
{
options = {
enable = mkEnableOption "nixvim";
defaultEditor = mkEnableOption "nixvim as the default editor";
};
}
(import ./modules/hm.nix {
inherit lib;
})
]
++ shared.topLevelModules;
};
Expand Down
7 changes: 7 additions & 0 deletions wrappers/modules/hm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{lib}:
with lib; {
options = {
enable = mkEnableOption "nixvim";
defaultEditor = mkEnableOption "nixvim as the default editor";
};
}

0 comments on commit 6d1ef58

Please sign in to comment.