at 23.05-pre 2.3 kB view raw
1{ pkgs ? (import ../.. {}), nixpkgs ? { }}: 2let 3 inherit (pkgs) lib; 4 inherit (lib) hasPrefix removePrefix; 5 6 locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs; }; 7 functionDocs = import ./lib-function-docs.nix { inherit locationsXml pkgs; }; 8 version = pkgs.lib.version; 9 10 epub-xsl = pkgs.writeText "epub.xsl" '' 11 <?xml version='1.0'?> 12 <xsl:stylesheet 13 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 14 version="1.0"> 15 <xsl:import href="${pkgs.docbook_xsl_ns}/xml/xsl/docbook/epub/docbook.xsl" /> 16 <xsl:import href="${./parameters.xml}"/> 17 </xsl:stylesheet> 18 ''; 19 20 xhtml-xsl = pkgs.writeText "xhtml.xsl" '' 21 <?xml version='1.0'?> 22 <xsl:stylesheet 23 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 24 version="1.0"> 25 <xsl:import href="${pkgs.docbook_xsl_ns}/xml/xsl/docbook/xhtml/docbook.xsl" /> 26 <xsl:import href="${./parameters.xml}"/> 27 </xsl:stylesheet> 28 ''; 29 30 # NB: This file describes the Nixpkgs manual, which happens to use module 31 # docs infra originally developed for NixOS. 32 optionsDoc = pkgs.nixosOptionsDoc { 33 inherit (pkgs.lib.evalModules { modules = [ ../../pkgs/top-level/config.nix ]; }) options; 34 documentType = "none"; 35 transformOptions = opt: 36 opt // { 37 declarations = 38 map 39 (decl: 40 if hasPrefix (toString ../..) (toString decl) 41 then 42 let subpath = removePrefix "/" (removePrefix (toString ../..) (toString decl)); 43 in { url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}"; name = subpath; } 44 else decl) 45 opt.declarations; 46 }; 47 }; 48 49in pkgs.runCommand "doc-support" {} 50'' 51 mkdir result 52 ( 53 cd result 54 ln -s ${locationsXml} ./function-locations.xml 55 ln -s ${functionDocs} ./function-docs 56 ln -s ${optionsDoc.optionsDocBook} ./config-options.docbook.xml 57 58 ln -s ${pkgs.docbook5}/xml/rng/docbook/docbook.rng ./docbook.rng 59 ln -s ${pkgs.docbook_xsl_ns}/xml/xsl ./xsl 60 ln -s ${epub-xsl} ./epub.xsl 61 ln -s ${xhtml-xsl} ./xhtml.xsl 62 63 ln -s ${../../nixos/doc/xmlformat.conf} ./xmlformat.conf 64 ln -s ${pkgs.documentation-highlighter} ./highlightjs 65 66 echo -n "${version}" > ./version 67 ) 68 mv result $out 69''