1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-10 10:02:36 +09:00

doc: make ./doc-support/lib-function-docs.nix callPackage style

Move `libsets` over to it, since it's the only user.

Format with `nixfmt` since we're changing it so dramatically.
This commit is contained in:
Philip Taron 2024-07-26 10:50:26 -07:00
parent 849cf13725
commit 87b8931d74
No known key found for this signature in database
2 changed files with 108 additions and 34 deletions

View file

@ -1,23 +1,111 @@
# Generates the documentation for library functions via nixdoc.
{ pkgs, nixpkgs, libsets }:
{
lib,
stdenvNoCC,
nixdoc,
nix,
nixpkgs ? { },
libsets ? [
{
name = "asserts";
description = "assertion functions";
}
{
name = "attrsets";
description = "attribute set functions";
}
{
name = "strings";
description = "string manipulation functions";
}
{
name = "versions";
description = "version string functions";
}
{
name = "trivial";
description = "miscellaneous functions";
}
{
name = "fixedPoints";
baseName = "fixed-points";
description = "explicit recursion functions";
}
{
name = "lists";
description = "list manipulation functions";
}
{
name = "debug";
description = "debugging functions";
}
{
name = "options";
description = "NixOS / nixpkgs option handling";
}
{
name = "path";
description = "path functions";
}
{
name = "filesystem";
description = "filesystem functions";
}
{
name = "fileset";
description = "file set functions";
}
{
name = "sources";
description = "source filtering functions";
}
{
name = "cli";
description = "command-line serialization functions";
}
{
name = "generators";
description = "functions that create file formats from nix data structures";
}
{
name = "gvariant";
description = "GVariant formatted string serialization functions";
}
{
name = "customisation";
description = "Functions to customise (derivation-related) functions, derivatons, or attribute sets";
}
{
name = "meta";
description = "functions for derivation metadata";
}
{
name = "derivations";
description = "miscellaneous derivation-specific functions";
}
],
}:
with pkgs;
stdenv.mkDerivation {
stdenvNoCC.mkDerivation {
name = "nixpkgs-lib-docs";
src = pkgs.lib.fileset.toSource {
src = lib.fileset.toSource {
root = ../..;
fileset = ../../lib;
};
buildInputs = [ nixdoc nix ];
buildInputs = [
nixdoc
nix
];
installPhase = ''
export NIX_STATE_DIR=$(mktemp -d)
nix-instantiate --eval --strict --json ${./lib-function-locations.nix} \
--arg nixpkgsPath "./." \
--argstr revision ${nixpkgs.rev or "master"} \
--argstr libsetsJSON ${pkgs.lib.escapeShellArg (builtins.toJSON libsets)} \
--argstr libsetsJSON ${lib.escapeShellArg (builtins.toJSON libsets)} \
> locations.json
function docgen {
@ -39,9 +127,16 @@ stdenv.mkDerivation {
```{=include=} sections auto-id-prefix=auto-generated
EOF
${lib.concatMapStrings ({ name, baseName ? name, description }: ''
docgen ${name} ${baseName} ${lib.escapeShellArg description}
'') libsets}
${lib.concatMapStrings (
{
name,
baseName ? name,
description,
}:
''
docgen ${name} ${baseName} ${lib.escapeShellArg description}
''
) libsets}
echo '```' >> "$out/index.md"
'';