nix-community.nixvim/man-docs/default.nix
Gaétan Lepage 5638a3f3a1
Update flake.lock (#760)
* flake.lock: Update

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/19cbff58383a4ae384dea4d1d0c823d72b49d614' (2023-11-22)
  → 'github:NixOS/nixpkgs/8cfef6986adfb599ba379ae53c9f5631ecd2fd9c' (2023-11-27)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/e558068cba67b23b4fbc5537173dbb43748a17e8' (2023-11-15)
  → 'github:cachix/pre-commit-hooks.nix/e5ee5c5f3844550c01d2131096c7271cec5e9b78' (2023-11-25)

* docs: Fix NixOS manpage generation

NixOS/nixpkgs#269942 changed the signature of the NixOS ManpageConverter
to require a header and a footer. As those were the only changes in
nixvim-render-docs, we now use nixos-render-docs directly.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Miguel Gross Valle <Iggle@users.noreply.github.com>
2023-11-29 10:30:27 +01:00

51 lines
1.5 KiB
Nix

{
pkgs,
modules,
}: let
nixvimPath = toString ./..;
gitHubDeclaration = user: repo: subpath: {
url = "https://github.com/${user}/${repo}/blob/master/${subpath}";
name = "<${repo}/${subpath}>";
};
in {
man-docs = let
eval = pkgs.lib.evalModules {
inherit modules;
};
options = pkgs.nixosOptionsDoc {
inherit (eval) options;
warningsAreErrors = false;
transformOptions = opt:
opt
// {
declarations =
map (
decl:
if pkgs.lib.hasPrefix nixvimPath (toString decl)
then
gitHubDeclaration "nix-community" "nixvim"
(pkgs.lib.removePrefix "/" (pkgs.lib.removePrefix nixvimPath (toString decl)))
else if decl == "lib/modules.nix"
then gitHubDeclaration "NixOS" "nixpkgs" decl
else decl
)
opt.declarations;
};
};
in
pkgs.runCommand "nixvim-configuration-reference-manpage" {
nativeBuildInputs = with pkgs; [installShellFiles nixos-render-docs];
} ''
# Generate man-pages
mkdir -p $out/share/man/man5
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
--revision unstable \
--header ${./nixvim-header.5} \
--footer ${./nixvim-footer.5} \
${options.optionsJSON}/share/doc/nixos/options.json \
$out/share/man/man5/nixvim.5
compressManPages $out
'';
}