1{ pkgs ? (import ../.. {}), nixpkgs ? { }}:
2let
3 inherit (pkgs) lib;
4 inherit (lib) hasPrefix removePrefix;
5
6 libsets = [
7 { name = "asserts"; description = "assertion functions"; }
8 { name = "attrsets"; description = "attribute set functions"; }
9 { name = "strings"; description = "string manipulation functions"; }
10 { name = "versions"; description = "version string functions"; }
11 { name = "trivial"; description = "miscellaneous functions"; }
12 { name = "lists"; description = "list manipulation functions"; }
13 { name = "debug"; description = "debugging functions"; }
14 { name = "options"; description = "NixOS / nixpkgs option handling"; }
15 { name = "path"; description = "path functions"; }
16 { name = "filesystem"; description = "filesystem functions"; }
17 { name = "sources"; description = "source filtering functions"; }
18 { name = "cli"; description = "command-line serialization functions"; }
19 ];
20
21 locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs libsets; };
22 functionDocs = import ./lib-function-docs.nix { inherit locationsXml pkgs libsets; };
23 version = pkgs.lib.version;
24
25 epub-xsl = pkgs.writeText "epub.xsl" ''
26 <?xml version='1.0'?>
27 <xsl:stylesheet
28 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
29 version="1.0">
30 <xsl:import href="${pkgs.docbook_xsl_ns}/xml/xsl/docbook/epub/docbook.xsl" />
31 <xsl:import href="${./parameters.xml}"/>
32 </xsl:stylesheet>
33 '';
34
35 xhtml-xsl = pkgs.writeText "xhtml.xsl" ''
36 <?xml version='1.0'?>
37 <xsl:stylesheet
38 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
39 version="1.0">
40 <xsl:import href="${pkgs.docbook_xsl_ns}/xml/xsl/docbook/xhtml/docbook.xsl" />
41 <xsl:import href="${./parameters.xml}"/>
42 </xsl:stylesheet>
43 '';
44
45 # NB: This file describes the Nixpkgs manual, which happens to use module
46 # docs infra originally developed for NixOS.
47 optionsDoc = pkgs.nixosOptionsDoc {
48 inherit (pkgs.lib.evalModules {
49 modules = [ ../../pkgs/top-level/config.nix ];
50 class = "nixpkgsConfig";
51 }) options;
52 documentType = "none";
53 transformOptions = opt:
54 opt // {
55 declarations =
56 map
57 (decl:
58 if hasPrefix (toString ../..) (toString decl)
59 then
60 let subpath = removePrefix "/" (removePrefix (toString ../..) (toString decl));
61 in { url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}"; name = subpath; }
62 else decl)
63 opt.declarations;
64 };
65 };
66
67in pkgs.runCommand "doc-support" {}
68''
69 mkdir result
70 (
71 cd result
72 ln -s ${locationsXml} ./function-locations.xml
73 ln -s ${functionDocs} ./function-docs
74 ln -s ${optionsDoc.optionsDocBook} ./config-options.docbook.xml
75
76 ln -s ${pkgs.docbook5}/xml/rng/docbook/docbook.rng ./docbook.rng
77 ln -s ${pkgs.docbook_xsl_ns}/xml/xsl ./xsl
78 ln -s ${epub-xsl} ./epub.xsl
79 ln -s ${xhtml-xsl} ./xhtml.xsl
80
81 ln -s ${./xmlformat.conf} ./xmlformat.conf
82 ln -s ${pkgs.documentation-highlighter} ./highlightjs
83
84 echo -n "${version}" > ./version
85 )
86 mv result $out
87''