1{ stdenv, buildPackages, lib, haskellLib, ghc, ghcForComponent, nonReinstallablePkgs, runCommand, writeText, writeScript, makeConfigFiles }:
23, configFiles # component config files
27 doHaddock' = doHaddock
28 && (haskellLib.isLibrary componentId)
29 && !haskellLib.isCrossHost;
31 # the target dir for haddock documentation
32 docdir = docoutput: docoutput + "/share/doc/" + componentId.cname;
34 packageCfgDir = configFiles.packageCfgDir;
36 fullName = "${componentDrv.name}-haddock";
38 # These config files are like the one used in the build derivation,
39 # but `chooseDrv` will be used to map all the references to libraries
40 # to their haddock derivation.
41 docsConfigFiles = makeConfigFiles {
42 inherit (package) identifier;
43 inherit component fullName flags needsProfiling;
44 chooseDrv = p: p.haddock;
47 finalConfigureFlags = lib.concatStringsSep " " (
48 [ "--prefix=${componentDrv}"
49 "${haskellLib.componentTarget componentId}"
50 "$(cat ${docsConfigFiles}/configure-flags)"
52 ++ commonConfigureFlags
53 ++ lib.optional doHaddock' " --docdir=${docdir "$doc"}");
55 shellWrappers = ghcForComponent {
56 componentName = fullName;
57 configFiles = docsConfigFiles;
60 drv = stdenv.mkDerivation (commonAttrs // {
64 configFiles = docsConfigFiles;
66 # The directory containing the haddock documentation.
67 haddockDir = if doHaddock' then "${docdir drv.doc}/html" else null;
70 # `out` contains the `package.conf.d` files used for building the
72 # `doc` contains just the haddock output files.
74 ++ lib.optional doHaddock' "doc";
76 propagatedBuildInputs = builtins.concatLists pkgconfig;
78 buildInputs = component.libs
79 ++ map (d: d.components.library.haddock or d) component.depends;
82 [ shellWrappers buildPackages.removeReferencesTo ]
83 ++ componentDrv.executableToolDepends;
88 printf "%q " ${finalConfigureFlags}
90 $SETUP_HS configure ${finalConfigureFlags}
96 '' + lib.optionalString doHaddock' ''
99 docdir="${docdir "$doc"}"
100 # This mkdir needed for packages like base-noprelude and bytestring-builder
101 # (which is also empty when `bytestring >= 0.10.4`)
104 # If we don't have any source files, no need to run haddock
105 [[ -n $(find . -name "*.hs" -o -name "*.lhs") ]] && {
108 ${lib.optionalString doHoogle "--hoogle"} \
109 ${lib.optionalString hyperlinkSource "--hyperlink-source"} \
110 ${lib.optionalString quickjump "--quickjump"} \
111 ${lib.concatStringsSep " " (setupHaddockFlags ++ setupGhcOptions)}
118 target-pkg-and-db = "${ghc.targetPrefix}ghc-pkg -v0 --package-db $out/package.conf.d";
120 html="dist/doc/html/${package.identifier.name}"
122 if [ -d "$html" ]; then
123 # Ensure that libraries are not pulled into the docs closure.
124 # As an example, the prettified source code of a
125 # Paths_package module will contain store paths of the library package.
126 for x in "$html/src/"*.html; do
127 remove-references-to -t $out $x
128 remove-references-to -t ${componentDrv} $x
131 docdir="${docdir "$doc"}"
134 cp -R "$html" "$docdir"/html
137 ${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
139 for i in "${componentDrv}/package.conf.d"/*.conf; do
140 # Copy the .conf files from the build derivation, but replace the `haddock-intefaces:`
141 # field with correct location for haddocks (now it is known). This will insure that
142 # the other haddock derivations build to reference this one will have the correct
143 # working hyper links.
145 sed -e "s|haddock-interfaces:.*|haddock-interfaces: $docdir/html/${componentId.cname}.haddock|" -e "s|haddock-html:.*|haddock-html: $docdir/html/|" "$i" > "$pkg"
146 ${ghc.targetPrefix}ghc-pkg -v0 --package-db ${docsConfigFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register "$pkg"
149 ln -s ${componentDrv}/exactDep $out/exactDep
150 ln -s ${componentDrv}/envDep $out/envDep
153 // haskellLib.optionalHooks {
154 inherit preHaddock postHaddock;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list