on iko/ghcjs-patch-master help sign in
Fail when haddock fails by default (#359)
bf7b6d9Alexander Bantyev
builder/comp-builder.nix+11−17
@@ -227,34 +227,28 @@ stdenv.mkDerivation ({
227
227
228 haddockPhase = ''
228 haddockPhase = ''
229 runHook preHaddock
229 runHook preHaddock
230+ # If we don't have any source files, no need to run haddock
231+ [[ -n $(find . -name "*.hs" -o -name "*.lhs") ]] && {
230 docdir="${docdir "$doc"}"
232 docdir="${docdir "$doc"}"
231 mkdir -p "$docdir"
233 mkdir -p "$docdir"
232
234
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).
239 $SETUP_HS haddock \
235 $SETUP_HS haddock \
240 "--html" \
236 "--html" \
241 ${lib.optionalString doHoogle "--hoogle"} \
237 ${lib.optionalString doHoogle "--hoogle"} \
242 ${lib.optionalString hyperlinkSource "--hyperlink-source"} \
238 ${lib.optionalString hyperlinkSource "--hyperlink-source"} \
243 ${lib.concatStringsSep " " (component.setupHaddockFlags ++ setupGhcOptions)} \
239 ${lib.concatStringsSep " " (component.setupHaddockFlags ++ setupGhcOptions)} \
244− || true
245
240
246 html="dist/doc/html/${componentId.cname}"
241 html="dist/doc/html/${componentId.cname}"
247
242
248− if [ -d "$html" ]; then
249− # Ensure that libraries are not pulled into the docs closure.
243+ # Ensure that libraries are not pulled into the docs closure.
250− # As an example, the prettified source code of a
244+ # As an example, the prettified source code of a
251− # Paths_package module will contain store paths of the library package.
245+ # Paths_package module will contain store paths of the library package.
252− for x in "$html/src/"*.html; do
246+ for x in "$html/src/"*.html; do
253− remove-references-to -t $out $x
247+ remove-references-to -t $out $x
254− done
248+ done
255−
249+
256− cp -R "$html" "$docdir"/html
250+ cp -R "$html" "$docdir"/html
257− fi
251+ }
258 runHook postHaddock
252 runHook postHaddock
259 '';
253 '';
260
254