git.iko.soy/typeable/cabal2nix
on master help sign in
Merge pull request #406 from NixOS/revert-405-internal-haddock-revert

Revert "Revert "Disable Haddock phase for packages with internal libraries.""

commit0b4d75871c38dee3a920c870b132c80acc403022 authorPeter Simons <simons@cryp.to> dateMon 18 Feb 2019, 08:51 (8 years ago) parent0bbcfe4c92811b
3 files changed+153−1
src/Distribution/Nixpkgs/Haskell/FromCabal.hs+6−1 test/golden-test-cases/haddock-library.cabal+130 test/golden-test-cases/haddock-library.nix.golden+17
src/Distribution/Nixpkgs/Haskell/FromCabal.hs+6−1
@@ -88,7 +88,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
8888 & Nix.setupDepends .~ maybe mempty convertSetupBuildInfo setupBuildInfo
8989 & configureFlags .~ mempty
9090 & cabalFlags .~ flags
91− & runHaddock .~ maybe True (not . null . exposedModules) library
91+ & runHaddock .~ doHaddockPhase
9292 & jailbreak .~ False
9393 & doCheck .~ True
9494 & doBenchmark .~ False
@@ -150,6 +150,11 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
150150 internalLibNames :: [PackageName]
151151 internalLibNames = fmap unqualComponentNameToPackageName . catMaybes $ libName <$> subLibraries
152152
153+ doHaddockPhase :: Bool
154+ doHaddockPhase | not (null internalLibNames) = False
155+ | Just l <- library = not (null (exposedModules l))
156+ | otherwise = True
157+
153158 convertBuildInfo :: Cabal.BuildInfo -> Nix.BuildInfo
154159 convertBuildInfo Cabal.BuildInfo {..} | not buildable = mempty
155160 convertBuildInfo Cabal.BuildInfo {..} = mempty
test/golden-test-cases/haddock-library.cabalnew file+130
@@ -0,0 +1,130 @@
1+name: haddock-library
2+version: 1.4.5
3+synopsis: Library exposing some functionality of Haddock.
4+description: Haddock is a documentation-generation tool for Haskell
5+ libraries. These modules expose some functionality of it
6+ without pulling in the GHC dependency. Please note that the
7+ API is likely to change so specify upper bounds in your
8+ project if you can't release often. For interacting with Haddock
9+ itself, see the ‘haddock’ package.
10+license: BSD3
11+license-file: LICENSE
12+maintainer: Alex Biehl <alexbiehl@gmail.com>, Simon Hengel <sol@typeful.net>, Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>
13+homepage: http://www.haskell.org/haddock/
14+bug-reports: https://github.com/haskell/haddock/issues
15+category: Documentation
16+build-type: Simple
17+cabal-version: >= 2.0
18+extra-source-files:
19+ CHANGES.md
20+library
21+ default-language: Haskell2010
22+
23+ build-depends:
24+ base >= 4.5 && < 4.11
25+ , bytestring >= 0.9.2.1 && < 0.11
26+ , transformers >= 0.3.0 && < 0.6
27+
28+ -- internal sub-lib
29+ build-depends: attoparsec
30+
31+ hs-source-dirs: src
32+ ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2
33+
34+ exposed-modules:
35+ Documentation.Haddock.Doc
36+ Documentation.Haddock.Markup
37+ Documentation.Haddock.Parser
38+ Documentation.Haddock.Parser.Monad
39+ Documentation.Haddock.Types
40+ Documentation.Haddock.Utf8
41+
42+ other-modules:
43+ Documentation.Haddock.Parser.Util
44+
45+ ghc-options: -Wall
46+ if impl(ghc >= 8.0)
47+ ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
48+
49+library attoparsec
50+ default-language: Haskell2010
51+
52+ build-depends:
53+ base >= 4.5 && < 4.11
54+ , bytestring >= 0.9.2.1 && < 0.11
55+ , deepseq >= 1.3 && < 1.5
56+
57+ hs-source-dirs: vendor/attoparsec-0.13.1.0
58+
59+ -- NB: haddock-library needs only small part of lib:attoparsec
60+ -- internally, so we only bundle that subset here
61+ exposed-modules:
62+ Data.Attoparsec.ByteString
63+ Data.Attoparsec.ByteString.Char8
64+
65+ other-modules:
66+ Data.Attoparsec
67+ Data.Attoparsec.ByteString.Buffer
68+ Data.Attoparsec.ByteString.FastSet
69+ Data.Attoparsec.ByteString.Internal
70+ Data.Attoparsec.Combinator
71+ Data.Attoparsec.Internal
72+ Data.Attoparsec.Internal.Fhthagn
73+ Data.Attoparsec.Internal.Types
74+ Data.Attoparsec.Number
75+
76+ ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2
77+
78+ ghc-options: -Wall
79+ if impl(ghc >= 8.0)
80+ ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
81+ else
82+ build-depends: semigroups ^>= 0.18.3, fail ^>= 4.9.0.0
83+
84+
85+test-suite spec
86+ type: exitcode-stdio-1.0
87+ default-language: Haskell2010
88+ main-is: Spec.hs
89+ hs-source-dirs:
90+ test
91+ , src
92+ ghc-options: -Wall
93+
94+ cpp-options:
95+ -DTEST
96+
97+ other-modules:
98+ Documentation.Haddock.Doc
99+ Documentation.Haddock.Parser
100+ Documentation.Haddock.Parser.Monad
101+ Documentation.Haddock.Parser.Util
102+ Documentation.Haddock.Parser.UtilSpec
103+ Documentation.Haddock.ParserSpec
104+ Documentation.Haddock.Types
105+ Documentation.Haddock.Utf8
106+ Documentation.Haddock.Utf8Spec
107+
108+ build-depends:
109+ base-compat ^>= 0.9.3
110+ , transformers >= 0.3.0 && < 0.6
111+ , hspec ^>= 2.4.4
112+ , QuickCheck ^>= 2.10
113+
114+ -- internal sub-lib
115+ build-depends: attoparsec
116+
117+ -- Versions for the dependencies below are transitively pinned by
118+ -- dependency on haddock-library:lib:attoparsec
119+ build-depends:
120+ base
121+ , bytestring
122+ , deepseq
123+
124+ build-tool-depends:
125+ hspec-discover:hspec-discover ^>= 2.4.4
126+
127+source-repository head
128+ type: git
129+ subdir: haddock-library
130+ location: https://github.com/haskell/haddock.git
test/golden-test-cases/haddock-library.nix.goldennew file+17
@@ -0,0 +1,17 @@
1+{ mkDerivation, base, base-compat, bytestring, deepseq, hspec
2+, hspec-discover, QuickCheck, stdenv, transformers
3+}:
4+mkDerivation {
5+ pname = "haddock-library";
6+ version = "1.4.5";
7+ sha256 = "deadbeef";
8+ libraryHaskellDepends = [ base bytestring deepseq transformers ];
9+ testHaskellDepends = [
10+ base base-compat bytestring deepseq hspec QuickCheck transformers
11+ ];
12+ testToolDepends = [ hspec-discover ];
13+ doHaddock = false;
14+ homepage = "http://www.haskell.org/haddock/";
15+ description = "Library exposing some functionality of Haddock";
16+ license = stdenv.lib.licenses.bsd3;
17+}