@@ -227,34 +227,28 @@ stdenv.mkDerivation ({
227227
228228 haddockPhase = ''
229229 runHook preHaddock
230+ # If we don't have any source files, no need to run haddock
231+ [[ -n $(find . -name "*.hs" -o -name "*.lhs") ]] && {
230232 docdir="${docdir "$doc"}"
231233 mkdir -p "$docdir"
232234
233− # We accept that this might not produce any
234− # output (hence the || true). Depending of
235− # configuration flags, there might just be no
236− # modules to run haddock on. E.g. a package
237− # might turn into an empty one (see the fail
238− # pkg).
239235 $SETUP_HS haddock \
240236 "--html" \
241237 ${lib.optionalString doHoogle "--hoogle"} \
242238 ${lib.optionalString hyperlinkSource "--hyperlink-source"} \
243239 ${lib.concatStringsSep " " (component.setupHaddockFlags ++ setupGhcOptions)} \
244− || true
245240
246241 html="dist/doc/html/${componentId.cname}"
247242
248− if [ -d "$html" ]; then
249− # Ensure that libraries are not pulled into the docs closure.
250− # As an example, the prettified source code of a
251− # Paths_package module will contain store paths of the library package.
252− for x in "$html/src/"*.html; do
253− remove-references-to -t $out $x
254− done
255−
256− cp -R "$html" "$docdir"/html
257− fi
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
251+ }
258252 runHook postHaddock
259253 '';
260254