1 # Generates the documentation for library functions via nixdoc.
2 # To build this derivation, run `nix-build -A nixpkgs-manual.lib-docs`
12 description = "assertion functions";
16 description = "attribute set functions";
20 description = "string manipulation functions";
24 description = "version string functions";
28 description = "miscellaneous functions";
32 baseName = "fixed-points";
33 description = "explicit recursion functions";
37 description = "list manipulation functions";
41 description = "debugging functions";
45 description = "NixOS / nixpkgs option handling";
49 description = "path functions";
53 description = "filesystem functions";
57 description = "file set functions";
61 description = "source filtering functions";
65 description = "command-line serialization functions";
69 description = "functions that create file formats from nix data structures";
73 description = "GVariant formatted string serialization functions";
76 name = "customisation";
77 description = "Functions to customise (derivation-related) functions, derivatons, or attribute sets";
81 description = "functions for derivation metadata";
85 description = "miscellaneous derivation-specific functions";
90 stdenvNoCC.mkDerivation {
91 name = "nixpkgs-lib-docs";
93 src = lib.fileset.toSource {
104 export NIX_STATE_DIR=$(mktemp -d)
105 nix-instantiate --eval --strict --json ${./lib-function-locations.nix} \
106 --arg nixpkgsPath "./." \
107 --argstr revision ${nixpkgs.rev or "master"} \
108 --argstr libsetsJSON ${lib.escapeShellArg (builtins.toJSON libsets)} \
109 --store $(mktemp -d) \
116 # TODO: wrap lib.$name in <literal>, make nixdoc not escape it
117 if [[ -e "lib/$baseName.nix" ]]; then
118 nixdoc -c "$name" -d "lib.$name: $description" -l locations.json -f "lib/$baseName.nix" > "$out/$name.md"
120 nixdoc -c "$name" -d "lib.$name: $description" -l locations.json -f "lib/$baseName/default.nix" > "$out/$name.md"
122 echo "$out/$name.md" >> "$out/index.md"
127 cat > "$out/index.md" << 'EOF'
128 ```{=include=} sections auto-id-prefix=auto-generated
131 ${lib.concatMapStrings (
138 docgen ${name} ${baseName} ${lib.escapeShellArg description}
142 echo '```' >> "$out/index.md"