1 { pkgs ? (import ./.. { }), nixpkgs ? { }}:
4 inherit (lib) hasPrefix removePrefix;
6 common = import ./common.nix;
8 lib-docs = import ./doc-support/lib-function-docs.nix {
11 { name = "asserts"; description = "assertion functions"; }
12 { name = "attrsets"; description = "attribute set functions"; }
13 { name = "strings"; description = "string manipulation functions"; }
14 { name = "versions"; description = "version string functions"; }
15 { name = "trivial"; description = "miscellaneous functions"; }
16 { name = "fixedPoints"; baseName = "fixed-points"; description = "explicit recursion functions"; }
17 { name = "lists"; description = "list manipulation functions"; }
18 { name = "debug"; description = "debugging functions"; }
19 { name = "options"; description = "NixOS / nixpkgs option handling"; }
20 { name = "path"; description = "path functions"; }
21 { name = "filesystem"; description = "filesystem functions"; }
22 { name = "fileset"; description = "file set functions"; }
23 { name = "sources"; description = "source filtering functions"; }
24 { name = "cli"; description = "command-line serialization functions"; }
25 { name = "gvariant"; description = "GVariant formatted string serialization functions"; }
26 { name = "customisation"; description = "Functions to customise (derivation-related) functions, derivatons, or attribute sets"; }
27 { name = "meta"; description = "functions for derivation metadata"; }
28 { name = "derivations"; description = "miscellaneous derivation-specific functions"; }
32 epub = pkgs.runCommand "manual.epub" {
33 nativeBuildInputs = with pkgs; [ libxslt zip ];
36 <book xmlns="http://docbook.org/ns/docbook"
37 xmlns:xlink="http://www.w3.org/1999/xlink"
39 xml:id="nixpkgs-manual">
41 <title>Nixpkgs Manual</title>
42 <subtitle>Version ${pkgs.lib.version}</subtitle>
45 <title>Temporarily unavailable</title>
47 The Nixpkgs manual is currently not available in EPUB format,
48 please use the <link xlink:href="https://nixos.org/nixpkgs/manual">HTML manual</link>
52 If you've used the EPUB manual in the past and it has been useful to you, please
53 <link xlink:href="https://github.com/NixOS/nixpkgs/issues/237234">let us know</link>.
59 passAsFile = [ "epub" ];
63 --param chapter.autolabel 0 \
66 ${pkgs.docbook_xsl_ns}/xml/xsl/docbook/epub/docbook.xsl \
69 echo "application/epub+zip" > mimetype
70 zip -0Xq "$out" mimetype
71 cd scratch && zip -Xr9D "$out" *
74 # NB: This file describes the Nixpkgs manual, which happens to use module
75 # docs infra originally developed for NixOS.
76 optionsDoc = pkgs.nixosOptionsDoc {
77 inherit (pkgs.lib.evalModules {
78 modules = [ ../pkgs/top-level/config.nix ];
79 class = "nixpkgsConfig";
81 documentType = "none";
82 transformOptions = opt:
87 if hasPrefix (toString ../..) (toString decl)
89 let subpath = removePrefix "/" (removePrefix (toString ../.) (toString decl));
90 in { url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}"; name = subpath; }
95 in pkgs.stdenv.mkDerivation {
96 name = "nixpkgs-manual";
98 nativeBuildInputs = with pkgs; [
105 ln -s ${optionsDoc.optionsJSON}/share/doc/nixos/options.json ./config-options.json
110 ./functions/library.md.in \
111 ${lib-docs}/index.md \
112 > ./functions/library.md
113 substitute ./manual.md.in ./manual.md \
114 --replace-fail '@MANUAL_VERSION@' '${pkgs.lib.version}'
118 mkdir -p out/highlightjs
119 cp -t out/highlightjs \
120 ${pkgs.documentation-highlighter}/highlight.pack.js \
121 ${pkgs.documentation-highlighter}/LICENSE \
122 ${pkgs.documentation-highlighter}/mono-blue.css \
123 ${pkgs.documentation-highlighter}/loader.js
125 cp -t out ./style.css ./anchor.min.js ./anchor-use.js
127 nixos-render-docs manual html \
128 --manpage-urls ./manpage-urls.json \
129 --revision ${pkgs.lib.trivial.revisionWithDefault (pkgs.rev or "master")} \
130 --stylesheet style.css \
131 --stylesheet highlightjs/mono-blue.css \
132 --script ./highlightjs/highlight.pack.js \
133 --script ./highlightjs/loader.js \
134 --script ./anchor.min.js \
135 --script ./anchor-use.js \
137 --section-toc-depth 1 \
143 dest="$out/${common.outputPath}"
144 mkdir -p "$(dirname "$dest")"
146 mv "$dest/index.html" "$dest/${common.indexPath}"
148 cp ${epub} "$dest/nixpkgs-manual.epub"
150 mkdir -p $out/nix-support/
151 echo "doc manual $dest ${common.indexPath}" >> $out/nix-support/hydra-build-products
152 echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products
155 passthru.tests.manpage-urls = with pkgs; testers.invalidateFetcherByDrvHash
156 ({ name ? "manual_check-manpage-urls"
160 nativeBuildInputs = [
162 (python3.withPackages (p: with p; [
168 outputHash = "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="; # Empty output
170 python3 ${script} ${urlsFile}
173 script = ./tests/manpage-urls.py;
174 urlsFile = ./manpage-urls.json;