2023-02-01 19:11:37 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
2023-10-03 19:08:35 +00:00
|
|
|
lib ? import ../lib/stdlib-extended.nix pkgs.lib,
|
2023-02-01 19:11:37 +00:00
|
|
|
nmdSrc,
|
2023-12-09 19:03:58 +00:00
|
|
|
...
|
2023-02-01 19:11:37 +00:00
|
|
|
}: let
|
2023-09-27 13:06:12 +00:00
|
|
|
nmd = import nmdSrc {
|
|
|
|
inherit lib;
|
|
|
|
# The DocBook output of `nixos-render-docs` doesn't have the change
|
|
|
|
# `nmd` uses to work around the broken stylesheets in
|
|
|
|
# `docbook-xsl-ns`, so we restore the patched version here.
|
|
|
|
pkgs =
|
|
|
|
pkgs
|
|
|
|
// {
|
|
|
|
docbook-xsl-ns =
|
|
|
|
pkgs.docbook-xsl-ns.override {withManOptDedupPatch = true;};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Make sure the used package is scrubbed to avoid actually
|
|
|
|
# instantiating derivations.
|
2023-02-01 19:11:37 +00:00
|
|
|
scrubbedPkgsModule = {
|
|
|
|
imports = [
|
|
|
|
{
|
|
|
|
_module.args = {
|
|
|
|
pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs);
|
2023-09-27 13:06:12 +00:00
|
|
|
pkgs_i686 = lib.mkForce {};
|
2023-02-01 19:11:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-12-09 19:03:58 +00:00
|
|
|
dontCheckDefinitions = {_module.check = false;};
|
|
|
|
|
2023-11-04 11:30:04 +00:00
|
|
|
githubDeclaration = user: repo: subpath: let
|
|
|
|
urlRef = "main";
|
|
|
|
in {
|
|
|
|
url = "https://github.com/${user}/${repo}/blob/${urlRef}/${subpath}";
|
|
|
|
name = "<${repo}/${subpath}>";
|
|
|
|
};
|
|
|
|
|
2023-12-09 19:03:58 +00:00
|
|
|
hmPath = toString ./..;
|
2023-11-04 11:30:04 +00:00
|
|
|
|
|
|
|
buildOptionsDocs = args @ {
|
|
|
|
modules,
|
2023-12-09 19:03:58 +00:00
|
|
|
includeModuleSystemOptions ? true,
|
2023-11-04 11:30:04 +00:00
|
|
|
...
|
|
|
|
}: let
|
2023-12-09 19:03:58 +00:00
|
|
|
inherit ((lib.evalModules {inherit modules;})) options;
|
2023-11-04 11:30:04 +00:00
|
|
|
in
|
2023-12-09 19:03:58 +00:00
|
|
|
pkgs.buildPackages.nixosOptionsDoc ({
|
2023-11-04 11:30:04 +00:00
|
|
|
options =
|
2023-12-09 19:03:58 +00:00
|
|
|
if includeModuleSystemOptions
|
2023-11-04 11:30:04 +00:00
|
|
|
then options
|
2023-12-09 19:03:58 +00:00
|
|
|
else builtins.removeAttrs options ["_module"];
|
2023-11-04 11:30:04 +00:00
|
|
|
transformOptions = opt:
|
|
|
|
opt
|
|
|
|
// {
|
2023-12-09 19:03:58 +00:00
|
|
|
# Clean up declaration sites to not refer to the Home Manager
|
|
|
|
# source tree.
|
|
|
|
declarations = map (decl:
|
|
|
|
if lib.hasPrefix hmPath (toString decl)
|
|
|
|
then
|
|
|
|
githubDeclaration "notashelf" "neovim-flake"
|
|
|
|
(lib.removePrefix "/" (lib.removePrefix hmPath (toString decl)))
|
|
|
|
else if decl == "lib/modules.nix"
|
|
|
|
then
|
|
|
|
# TODO: handle this in a better way (may require upstream
|
|
|
|
# changes to nixpkgs)
|
|
|
|
githubDeclaration "NixOS" "nixpkgs" decl
|
|
|
|
else decl)
|
|
|
|
opt.declarations;
|
2023-11-04 11:30:04 +00:00
|
|
|
};
|
|
|
|
}
|
2023-12-09 19:03:58 +00:00
|
|
|
// builtins.removeAttrs args ["modules" "includeModuleSystemOptions"]);
|
2023-11-04 11:30:04 +00:00
|
|
|
|
|
|
|
nvimModuleDocs = buildOptionsDocs {
|
2023-02-01 19:11:37 +00:00
|
|
|
modules =
|
2023-12-09 19:03:58 +00:00
|
|
|
import ../modules/modules.nix {
|
|
|
|
inherit lib pkgs;
|
2023-02-01 19:11:37 +00:00
|
|
|
check = false;
|
|
|
|
}
|
2023-11-04 11:30:04 +00:00
|
|
|
++ [scrubbedPkgsModule];
|
|
|
|
variablelistId = "neovim-flake-options";
|
2023-02-01 19:11:37 +00:00
|
|
|
};
|
|
|
|
|
2023-12-09 19:03:58 +00:00
|
|
|
release-config = builtins.fromJSON (builtins.readFile ../release.json);
|
|
|
|
revision = "release-${release-config.release}";
|
|
|
|
# Generate the `man home-configuration.nix` package
|
|
|
|
home-configuration-manual =
|
|
|
|
pkgs.runCommand "neovim-flake-reference-manpage" {
|
|
|
|
nativeBuildInputs = [pkgs.buildPackages.installShellFiles pkgs.nixos-render-docs];
|
|
|
|
allowedReferences = ["out"];
|
|
|
|
} ''
|
|
|
|
# Generate manpages.
|
|
|
|
mkdir -p $out/share/man/man5
|
|
|
|
mkdir -p $out/share/man/man1
|
|
|
|
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
|
|
|
|
--revision ${revision} \
|
|
|
|
--header ${./home-configuration-nix-header.5} \
|
|
|
|
--footer ${./home-configuration-nix-footer.5} \
|
|
|
|
${nvimModuleDocs.optionsJSON}/share/doc/nixos/options.json \
|
|
|
|
$out/share/man/man5/home-configuration.nix.5
|
|
|
|
cp ${./home-manager.1} $out/share/man/man1/home-manager.1
|
2023-02-01 19:11:37 +00:00
|
|
|
'';
|
2023-12-09 19:03:58 +00:00
|
|
|
# Generate the HTML manual pages
|
|
|
|
neovim-flake-manual = pkgs.callPackage ./manual.nix {
|
|
|
|
inherit revision;
|
|
|
|
outputPath = "share/doc/neovim-flake";
|
|
|
|
nmd = nmdSrc;
|
|
|
|
options = {
|
|
|
|
neovim-flake = nvimModuleDocs.optionsJSON;
|
|
|
|
};
|
2023-02-01 19:11:37 +00:00
|
|
|
};
|
2023-12-09 19:03:58 +00:00
|
|
|
html = neovim-flake-manual;
|
|
|
|
htmlOpenTool = pkgs.callPackage ./html-open-tool.nix {} {inherit html;};
|
2023-02-01 19:11:37 +00:00
|
|
|
in {
|
2023-12-09 19:03:58 +00:00
|
|
|
inherit nmdSrc;
|
2023-11-04 11:30:04 +00:00
|
|
|
|
2023-12-09 19:03:58 +00:00
|
|
|
options = {
|
|
|
|
# TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream
|
|
|
|
# `nixosOptionsDoc` is more customizable.
|
|
|
|
json =
|
|
|
|
pkgs.runCommand "options.json" {
|
|
|
|
meta.description = "List of Home Manager options in JSON format";
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/{share/doc,nix-support}
|
|
|
|
cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/home-manager
|
|
|
|
substitute \
|
|
|
|
${nvimModuleDocs.optionsJSON}/nix-support/hydra-build-products \
|
|
|
|
$out/nix-support/hydra-build-products \
|
|
|
|
--replace \
|
|
|
|
'${nvimModuleDocs.optionsJSON}/share/doc/nixos' \
|
|
|
|
"$out/share/doc/home-manager"
|
|
|
|
'';
|
|
|
|
};
|
2023-11-04 11:30:04 +00:00
|
|
|
|
2023-12-09 19:03:58 +00:00
|
|
|
manPages = home-configuration-manual;
|
|
|
|
manual = {inherit html htmlOpenTool;};
|
2023-02-01 19:11:37 +00:00
|
|
|
}
|