@@ -236,18 +236,20 @@ stdenv.mkDerivation ({
236236 "--html" \
237237 ${lib.optionalString doHoogle "--hoogle"} \
238238 ${lib.optionalString hyperlinkSource "--hyperlink-source"} \
239− ${lib.concatStringsSep " " (component.setupHaddockFlags ++ setupGhcOptions)} \
239+ ${lib.concatStringsSep " " (component.setupHaddockFlags ++ setupGhcOptions)}
240240
241241 html="dist/doc/html/${componentId.cname}"
242242
243− # Ensure that libraries are not pulled into the docs closure.
244− # As an example, the prettified source code of a
245− # Paths_package module will contain store paths of the library package.
246− for x in "$html/src/"*.html; do
247− remove-references-to -t $out $x
248− done
249−
250− cp -R "$html" "$docdir"/html
243+ if [ -d "$html" ]; then
244+ # Ensure that libraries are not pulled into the docs closure.
245+ # As an example, the prettified source code of a
246+ # Paths_package module will contain store paths of the library package.
247+ for x in "$html/src/"*.html; do
248+ remove-references-to -t $out $x
249+ done
250+
251+ cp -R "$html" "$docdir"/html
252+ fi
251253 }
252254 runHook postHaddock
253255 '';