2023-02-01 19:11:37 +00:00
|
|
|
{
|
2024-04-09 07:02:58 +00:00
|
|
|
inputs,
|
2023-02-01 19:11:37 +00:00
|
|
|
pkgs,
|
2024-07-11 22:49:44 +00:00
|
|
|
lib,
|
2023-02-01 19:11:37 +00:00
|
|
|
}: let
|
2024-09-22 19:52:10 +00:00
|
|
|
inherit ((lib.importJSON ../release.json)) release;
|
2024-04-18 18:07:19 +00:00
|
|
|
|
2024-09-22 19:52:10 +00:00
|
|
|
nvimModuleDocs = pkgs.nixosOptionsDoc {
|
|
|
|
variablelistId = "nvf-options";
|
|
|
|
warningsAreErrors = true;
|
|
|
|
|
|
|
|
inherit
|
|
|
|
(
|
|
|
|
(lib.evalModules {
|
|
|
|
modules =
|
|
|
|
import ../modules/modules.nix {
|
|
|
|
inherit lib pkgs;
|
|
|
|
}
|
|
|
|
++ [
|
|
|
|
(
|
|
|
|
let
|
|
|
|
# From nixpkgs:
|
|
|
|
#
|
|
|
|
# Recursively replace each derivation in the given attribute set
|
|
|
|
# with the same derivation but with the `outPath` attribute set to
|
|
|
|
# the string `"\${pkgs.attribute.path}"`. This allows the
|
|
|
|
# documentation to refer to derivations through their values without
|
|
|
|
# establishing an actual dependency on the derivation output.
|
|
|
|
#
|
|
|
|
# This is not perfect, but it seems to cover a vast majority of use
|
|
|
|
# cases.
|
|
|
|
#
|
|
|
|
# Caveat: even if the package is reached by a different means, the
|
|
|
|
# path above will be shown and not e.g.
|
|
|
|
# `${config.services.foo.package}`.
|
|
|
|
scrubDerivations = namePrefix: pkgSet:
|
|
|
|
builtins.mapAttrs (
|
|
|
|
name: value: let
|
|
|
|
wholeName = "${namePrefix}.${name}";
|
|
|
|
in
|
|
|
|
if builtins.isAttrs value
|
|
|
|
then
|
|
|
|
scrubDerivations wholeName value
|
|
|
|
// lib.optionalAttrs (lib.isDerivation value) {
|
|
|
|
inherit (value) drvPath;
|
|
|
|
outPath = "\${${wholeName}}";
|
|
|
|
}
|
|
|
|
else value
|
|
|
|
)
|
|
|
|
pkgSet;
|
|
|
|
in {
|
|
|
|
_module = {
|
|
|
|
check = false;
|
|
|
|
args.pkgs = lib.mkForce (scrubDerivations "pkgs" pkgs);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
];
|
|
|
|
})
|
|
|
|
)
|
|
|
|
options
|
|
|
|
;
|
|
|
|
|
|
|
|
transformOptions = opt:
|
|
|
|
opt
|
|
|
|
// {
|
|
|
|
declarations =
|
|
|
|
map (
|
|
|
|
decl:
|
|
|
|
if lib.hasPrefix (toString ../.) (toString decl)
|
2023-12-09 19:03:58 +00:00
|
|
|
then
|
2024-09-22 19:52:10 +00:00
|
|
|
lib.pipe decl [
|
|
|
|
toString
|
|
|
|
(lib.removePrefix (toString ../.))
|
|
|
|
(lib.removePrefix "/")
|
|
|
|
(x: {
|
|
|
|
url = "https://github.com/NotAShelf/nvf/blob/main/${decl}";
|
|
|
|
name = "<nvf/${x}>";
|
|
|
|
})
|
|
|
|
]
|
2023-12-09 19:03:58 +00:00
|
|
|
else if decl == "lib/modules.nix"
|
2024-09-22 19:52:10 +00:00
|
|
|
then {
|
|
|
|
url = "https://github.com/NixOS/nixpkgs/blob/master/${decl}";
|
|
|
|
name = "<nixpkgs/lib/modules.nix>";
|
|
|
|
}
|
|
|
|
else decl
|
|
|
|
)
|
|
|
|
opt.declarations;
|
|
|
|
};
|
|
|
|
};
|
2024-04-18 18:07:19 +00:00
|
|
|
|
2024-09-22 19:52:10 +00:00
|
|
|
# Generate the HTML manual pages
|
|
|
|
html = pkgs.callPackage ./manual.nix {
|
|
|
|
inherit release;
|
|
|
|
inherit (nvimModuleDocs) optionsJSON;
|
2023-02-01 19:11:37 +00:00
|
|
|
};
|
2024-09-22 19:52:10 +00:00
|
|
|
in {
|
|
|
|
inherit (inputs) nmd;
|
|
|
|
|
|
|
|
# TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream
|
|
|
|
# `nixosOptionsDoc` is more customizable.
|
|
|
|
options.json =
|
|
|
|
pkgs.runCommand "options.json"
|
|
|
|
{
|
|
|
|
meta.description = "List of nvf options in JSON format";
|
|
|
|
}
|
|
|
|
''
|
|
|
|
mkdir -p $out/{share/doc,nix-support}
|
|
|
|
cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/nvf
|
|
|
|
substitute \
|
|
|
|
${nvimModuleDocs.optionsJSON}/nix-support/hydra-build-products \
|
|
|
|
$out/nix-support/hydra-build-products \
|
|
|
|
--replace \
|
|
|
|
'${nvimModuleDocs.optionsJSON}/share/doc/nixos' \
|
|
|
|
"$out/share/doc/nvf"
|
|
|
|
'';
|
2023-02-01 19:11:37 +00:00
|
|
|
|
2023-12-09 19:03:58 +00:00
|
|
|
# Generate the `man home-configuration.nix` package
|
2024-09-22 19:52:10 +00:00
|
|
|
manPages =
|
|
|
|
pkgs.runCommand "nvf-reference-manpage"
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgs.buildPackages.installShellFiles
|
|
|
|
pkgs.nixos-render-docs
|
|
|
|
];
|
2023-12-09 19:03:58 +00:00
|
|
|
allowedReferences = ["out"];
|
2024-09-22 19:52:10 +00:00
|
|
|
}
|
|
|
|
''
|
2023-12-09 19:03:58 +00:00
|
|
|
# Generate manpages.
|
2024-09-22 19:52:10 +00:00
|
|
|
mkdir -p $out/share/man/{man5,man1}
|
2024-04-09 08:16:23 +00:00
|
|
|
|
2023-12-09 19:03:58 +00:00
|
|
|
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
|
2024-09-22 19:52:10 +00:00
|
|
|
--revision ${release} \
|
2024-04-20 21:29:17 +00:00
|
|
|
--header ${./man/header.5} \
|
|
|
|
--footer ${./man/footer.5} \
|
2023-12-09 19:03:58 +00:00
|
|
|
${nvimModuleDocs.optionsJSON}/share/doc/nixos/options.json \
|
2024-04-27 12:44:37 +00:00
|
|
|
$out/share/man/man5/nvf.5
|
2024-04-09 08:16:23 +00:00
|
|
|
|
2024-04-27 12:44:37 +00:00
|
|
|
cp ${./man/nvf.1} $out/share/man/man1/nvf.1
|
2023-02-01 19:11:37 +00:00
|
|
|
'';
|
2024-04-09 08:16:23 +00:00
|
|
|
|
2024-09-22 19:52:10 +00:00
|
|
|
manual = {
|
|
|
|
inherit html;
|
|
|
|
htmlOpenTool = pkgs.callPackage ./html-open-tool.nix {inherit html;};
|
2023-12-09 19:03:58 +00:00
|
|
|
};
|
2023-02-01 19:11:37 +00:00
|
|
|
}
|