2022-12-11 14:56:09 +00:00
|
|
|
# Generates the documentation for library functions via nixdoc.
|
2024-07-26 18:45:25 +00:00
|
|
|
# To build this derivation, run `nix-build -A nixpkgs-manual.lib-docs`
|
2024-07-26 17:50:26 +00:00
|
|
|
{
|
|
|
|
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";
|
2024-10-28 12:27:35 +00:00
|
|
|
description = "Functions to customise (derivation-related) functions, derivations, or attribute sets";
|
2024-07-26 17:50:26 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "meta";
|
|
|
|
description = "functions for derivation metadata";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "derivations";
|
|
|
|
description = "miscellaneous derivation-specific functions";
|
|
|
|
}
|
|
|
|
],
|
|
|
|
}:
|
2023-06-24 20:14:37 +00:00
|
|
|
|
2024-07-26 17:50:26 +00:00
|
|
|
stdenvNoCC.mkDerivation {
|
2018-12-30 00:10:19 +00:00
|
|
|
name = "nixpkgs-lib-docs";
|
2024-07-26 17:50:26 +00:00
|
|
|
|
|
|
|
src = lib.fileset.toSource {
|
2024-07-18 21:33:29 +00:00
|
|
|
root = ../..;
|
|
|
|
fileset = ../../lib;
|
|
|
|
};
|
2018-12-30 00:10:19 +00:00
|
|
|
|
2024-07-26 17:50:26 +00:00
|
|
|
buildInputs = [
|
|
|
|
nixdoc
|
|
|
|
nix
|
|
|
|
];
|
|
|
|
|
2018-12-30 00:10:19 +00:00
|
|
|
installPhase = ''
|
2024-07-18 21:33:29 +00:00
|
|
|
export NIX_STATE_DIR=$(mktemp -d)
|
|
|
|
nix-instantiate --eval --strict --json ${./lib-function-locations.nix} \
|
|
|
|
--arg nixpkgsPath "./." \
|
|
|
|
--argstr revision ${nixpkgs.rev or "master"} \
|
2024-07-26 17:50:26 +00:00
|
|
|
--argstr libsetsJSON ${lib.escapeShellArg (builtins.toJSON libsets)} \
|
2024-09-12 18:44:17 +00:00
|
|
|
--store $(mktemp -d) \
|
2024-07-18 21:33:29 +00:00
|
|
|
> locations.json
|
|
|
|
|
2018-12-30 00:10:19 +00:00
|
|
|
function docgen {
|
2023-07-08 16:43:36 +00:00
|
|
|
name=$1
|
|
|
|
baseName=$2
|
|
|
|
description=$3
|
|
|
|
# TODO: wrap lib.$name in <literal>, make nixdoc not escape it
|
2024-07-18 21:33:29 +00:00
|
|
|
if [[ -e "lib/$baseName.nix" ]]; then
|
|
|
|
nixdoc -c "$name" -d "lib.$name: $description" -l locations.json -f "lib/$baseName.nix" > "$out/$name.md"
|
2022-12-23 19:57:49 +00:00
|
|
|
else
|
2024-07-18 21:33:29 +00:00
|
|
|
nixdoc -c "$name" -d "lib.$name: $description" -l locations.json -f "lib/$baseName/default.nix" > "$out/$name.md"
|
2022-12-23 19:57:49 +00:00
|
|
|
fi
|
2023-07-08 16:43:36 +00:00
|
|
|
echo "$out/$name.md" >> "$out/index.md"
|
2018-12-30 00:10:19 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 14:56:09 +00:00
|
|
|
mkdir -p "$out"
|
|
|
|
|
2023-03-25 20:38:26 +00:00
|
|
|
cat > "$out/index.md" << 'EOF'
|
2024-01-15 20:07:52 +00:00
|
|
|
```{=include=} sections auto-id-prefix=auto-generated
|
2022-12-11 14:56:09 +00:00
|
|
|
EOF
|
|
|
|
|
2024-07-26 17:50:26 +00:00
|
|
|
${lib.concatMapStrings (
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
baseName ? name,
|
|
|
|
description,
|
|
|
|
}:
|
|
|
|
''
|
|
|
|
docgen ${name} ${baseName} ${lib.escapeShellArg description}
|
|
|
|
''
|
|
|
|
) libsets}
|
2018-12-30 00:10:19 +00:00
|
|
|
|
2023-03-25 20:38:26 +00:00
|
|
|
echo '```' >> "$out/index.md"
|
2018-12-30 00:10:19 +00:00
|
|
|
'';
|
|
|
|
}
|