@@ -0,0 +1,92 @@
1+{ pkgs
2+, haskell
3+, stdenv
4+}:
5+
6+with stdenv.lib;
7+
8+let
9+ pkgSet = haskell.mkPkgSet {
10+ inherit pkgs;
11+ # generated with:
12+ # cabal new-build
13+ # plan-to-nix dist-newstyle/cache/plan.json > plan.nix
14+ # cabal-to-nix test-haddock.cabal > test-haddock.nix
15+ pkg-def = import ./plan.nix;
16+ pkg-def-overlays = [
17+ { test-haddock = ./test-haddock.nix; }
18+ ];
19+ modules = [
20+ # overrides to fix the build
21+ {
22+ packages.transformers-compat.components.library.doExactConfig = true;
23+ }
24+
25+ {
26+ # Add a hook to the haddock phase
27+ packages.test-haddock.postHaddock = ''
28+ echo "==="
29+ echo "This is the postHaddock hook. The files are:"
30+ find .
31+ echo "==="
32+ '';
33+
34+ # Check that the package option works
35+ packages.stm.doHaddock = false;
36+ }
37+ ];
38+ };
39+
40+ packages = pkgSet.config.hsPkgs;
41+
42+in
43+ stdenv.mkDerivation {
44+ name = "builder-haddock-test";
45+
46+ buildCommand = let
47+ inherit (packages.test-haddock.components) library;
48+ noDocLibrary = packages.stm.components.library;
49+ in ''
50+ ########################################################################
51+ # test haddock
52+
53+ doc="${toString library.doc}"
54+ docDir="${toString library.haddockDir}"
55+
56+ # exeDoc="$ disabled {toString packages.test-haddock.components.exes.test-haddock.doc}"
57+ # printf "checking that executable output does not have docs ... " >& 2
58+ # echo $exeDoc
59+ # test "$exeDoc" = ""
60+
61+ printf "checking that documentation directory was built... " >& 2
62+ echo "$doc" >& 2
63+ test -n "$doc"
64+
65+ printf "checking that documentation was generated... " >& 2
66+ grep hello "$docDir/TestHaddock.html" > /dev/null
67+ echo yes >& 2
68+
69+ printf "checking for hoogle index of package... " >& 2
70+ grep hello "$docDir/test-haddock.txt" > /dev/null
71+ echo yes >& 2
72+
73+ printf "checking for absence of documentation in another package... " >& 2
74+ if [ -d "${toString noDocLibrary.haddockDir}" ]; then
75+ echo "it exists - FAIL" >& 2
76+ else
77+ echo PASS >& 2
78+ fi
79+
80+ printf "checking for absence of library package store paths in docs... " >& 2
81+ if grep -R ${library} "$docDir" > /dev/null; then
82+ echo "Found ${library} - FAIL" >& 2
83+ exit 1
84+ else
85+ echo "PASS" >& 2
86+ fi
87+
88+ touch $out
89+ '';
90+
91+ meta.platforms = platforms.all;
92+} // { inherit packages pkgSet; }