diff --git a/cabal2nix.cabal b/cabal2nix.cabal
--- a/cabal2nix.cabal
+++ b/cabal2nix.cabal
@@ -1,5 +1,5 @@
 name:           cabal2nix
-version:        2.9
+version:        2.9.1
 synopsis:       Convert Cabal files into Nix build instructions.
 category:       Distribution, Nix
 stability:      stable
@@ -105,7 +105,7 @@
     , containers
     , deepseq >=1.4
     , directory
-    , distribution-nixpkgs >=1.1
+    , distribution-nixpkgs >=1.1.1
     , filepath
     , hackage-db >=2.0.1
     , hopenssl >=2
@@ -160,7 +160,7 @@
     , cabal2nix
     , containers
     , directory
-    , distribution-nixpkgs >=1.1
+    , distribution-nixpkgs >=1.1.1
     , filepath
     , hopenssl >=2
     , language-nix
@@ -170,7 +170,6 @@
     , mtl
     , optparse-applicative
     , pretty >=1.1.2
-    , utf8-string
   other-modules:
       Paths_cabal2nix
       HackageGit
diff --git a/src/Distribution/Nixpkgs/Fetch.hs b/src/Distribution/Nixpkgs/Fetch.hs
--- a/src/Distribution/Nixpkgs/Fetch.hs
+++ b/src/Distribution/Nixpkgs/Fetch.hs
@@ -105,7 +105,7 @@
   localArchive :: FilePath -> MaybeT IO (DerivationSource, a)
   localArchive path = do
     absolutePath <- liftIO $ canonicalizePath path
-    unpacked <- snd <$> fetchWith (False, "zip", []) (Source ("file://" ++ absolutePath) "" UnknownHash ".")
+    unpacked <- snd <$> fetchWith (False, "url", ["--unpack"]) (Source ("file://" ++ absolutePath) "" UnknownHash ".")
     process (DerivationSource "" absolutePath "" "", unpacked)
 
   process :: (DerivationSource, FilePath) -> MaybeT IO (DerivationSource, a)
diff --git a/src/Distribution/Nixpkgs/Haskell/Derivation.hs b/src/Distribution/Nixpkgs/Haskell/Derivation.hs
--- a/src/Distribution/Nixpkgs/Haskell/Derivation.hs
+++ b/src/Distribution/Nixpkgs/Haskell/Derivation.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE DeriveGeneric #-}
 {-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE TemplateHaskell #-}
@@ -27,6 +28,10 @@
 import GHC.Generics ( Generic )
 import Language.Nix
 import Language.Nix.PrettyPrinting
+
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
 
 -- | A represtation of Nix expressions for building Haskell packages.
 -- The data type correspond closely to the definition of
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal.hs
@@ -89,7 +89,7 @@
     & Nix.setupDepends .~ maybe mempty convertSetupBuildInfo setupBuildInfo
     & configureFlags .~ mempty
     & cabalFlags .~ flags
-    & runHaddock .~ maybe True (not . null . exposedModules) library
+    & runHaddock .~ doHaddockPhase
     & jailbreak .~ False
     & doCheck .~ True
     & testTarget .~ mempty
@@ -140,6 +140,11 @@
 
     internalLibNames :: [PackageName]
     internalLibNames = fmap unqualComponentNameToPackageName . catMaybes $ libName <$> subLibraries
+
+    doHaddockPhase :: Bool
+    doHaddockPhase | not (null internalLibNames) = False
+                   | Just l <- library           = not (null (exposedModules l))
+                   | otherwise                   = True
 
     convertBuildInfo :: Cabal.BuildInfo -> Nix.BuildInfo
     convertBuildInfo Cabal.BuildInfo {..} | not buildable = mempty
diff --git a/src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs b/src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs
--- a/src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs
+++ b/src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs
@@ -7,6 +7,7 @@
 import Control.Monad
 import Control.Monad.IO.Class
 import Control.Monad.Trans.Maybe
+import Data.Bifunctor
 import qualified Data.ByteString.Char8 as BS -- TODO: Deal with utf-8 encoding!!
 import Data.List ( isSuffixOf, isPrefixOf )
 import qualified Data.Map as DB
@@ -19,6 +20,7 @@
 import Distribution.PackageDescription
 import qualified Distribution.PackageDescription as Cabal
 import Distribution.PackageDescription.Parsec as Cabal
+import Distribution.Parsec.Common (showPError)
 import Distribution.Text ( simpleParse, display )
 import Distribution.Version
 import qualified Hpack.Config as Hpack
@@ -199,12 +201,14 @@
     Right (Hpack.DecodeResult pkg' _ _) -> do
       let hpackOutput = Hpack.renderPackage [] pkg'
           hash = printSHA256 $ digestString (digestByName "sha256") hpackOutput
-      case parseGenericPackageDescriptionMaybe (BS.pack hpackOutput) of
-        Nothing -> liftIO $ do
-          hPutStrLn stderr "*** cannot parse hpack output:"
+      case runParseGenericPackageDescription "<hpack output>" (BS.pack hpackOutput) of
+        Left msg -> liftIO $ do
+          hPutStrLn stderr "*** hpack output:"
           hPutStrLn stderr hpackOutput
+          hPutStrLn stderr "*** cannot parse hpack output:"
+          hPutStrLn stderr msg
           fail "*** Exiting."
-        Just pkg -> MaybeT $ return $ Just $ (,) True $ setCabalFileHash hash pkg
+        Right pkg -> MaybeT $ return $ Just $ (,) True $ setCabalFileHash hash pkg
 
 cabalFromFile :: Bool -> FilePath -> MaybeT IO Cabal.GenericPackageDescription
 cabalFromFile failHard file =
@@ -216,9 +220,22 @@
       hSetEncoding h utf8
       hGetContents h >>= Exception.evaluate . force
     let hash = printSHA256 (digestString (digestByName "sha256") buf)
-    case parseGenericPackageDescriptionMaybe (BS.pack buf) of
-      Nothing  -> if failHard then fail ("cannot parse " ++ show file) else return Nothing
-      Just pkg -> return $ Just $ setCabalFileHash hash pkg
+    case runParseGenericPackageDescription file (BS.pack buf) of
+      Left msg | failHard -> liftIO $ do
+          hPutStrLn stderr $ "*** cannot parse " ++ show file ++ ":"
+          hPutStrLn stderr msg
+          fail "*** Exiting."
+      Left _ -> return Nothing
+      Right pkg -> return $ Just $ setCabalFileHash hash pkg
+
+runParseGenericPackageDescription
+  :: FilePath
+  -> BS.ByteString
+  -> Either String Cabal.GenericPackageDescription
+runParseGenericPackageDescription fpath
+  = first (unlines . fmap (showPError fpath) . snd)
+  . snd . runParseResult
+  . parseGenericPackageDescription
 
 setCabalFileHash :: String -> GenericPackageDescription -> GenericPackageDescription
 setCabalFileHash sha256 gpd = gpd { packageDescription = (packageDescription gpd) {
diff --git a/test/golden-test-cases/haddock-library.cabal b/test/golden-test-cases/haddock-library.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden-test-cases/haddock-library.cabal
@@ -0,0 +1,130 @@
+name:                 haddock-library
+version:              1.4.5
+synopsis:             Library exposing some functionality of Haddock.
+description:          Haddock is a documentation-generation tool for Haskell
+                      libraries. These modules expose some functionality of it
+                      without pulling in the GHC dependency. Please note that the
+                      API is likely to change so specify upper bounds in your
+                      project if you can't release often. For interacting with Haddock
+                      itself, see the ‘haddock’ package.
+license:              BSD3
+license-file:         LICENSE
+maintainer:           Alex Biehl <alexbiehl@gmail.com>, Simon Hengel <sol@typeful.net>, Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>
+homepage:             http://www.haskell.org/haddock/
+bug-reports:          https://github.com/haskell/haddock/issues
+category:             Documentation
+build-type:           Simple
+cabal-version:        >= 2.0
+extra-source-files:
+  CHANGES.md
+library
+  default-language:     Haskell2010
+
+  build-depends:
+      base         >= 4.5     && < 4.11
+    , bytestring   >= 0.9.2.1 && < 0.11
+    , transformers >= 0.3.0   && < 0.6
+
+  -- internal sub-lib
+  build-depends:        attoparsec
+
+  hs-source-dirs:       src
+  ghc-options:          -funbox-strict-fields -Wall -fwarn-tabs -O2
+
+  exposed-modules:
+    Documentation.Haddock.Doc
+    Documentation.Haddock.Markup
+    Documentation.Haddock.Parser
+    Documentation.Haddock.Parser.Monad
+    Documentation.Haddock.Types
+    Documentation.Haddock.Utf8
+
+  other-modules:
+    Documentation.Haddock.Parser.Util
+
+  ghc-options: -Wall
+  if impl(ghc >= 8.0)
+    ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
+
+library attoparsec
+  default-language:     Haskell2010
+
+  build-depends:
+      base         >= 4.5     && < 4.11
+    , bytestring   >= 0.9.2.1 && < 0.11
+    , deepseq      >= 1.3     && < 1.5
+
+  hs-source-dirs:       vendor/attoparsec-0.13.1.0
+
+  -- NB: haddock-library needs only small part of lib:attoparsec
+  --     internally, so we only bundle that subset here
+  exposed-modules:
+    Data.Attoparsec.ByteString
+    Data.Attoparsec.ByteString.Char8
+
+  other-modules:
+    Data.Attoparsec
+    Data.Attoparsec.ByteString.Buffer
+    Data.Attoparsec.ByteString.FastSet
+    Data.Attoparsec.ByteString.Internal
+    Data.Attoparsec.Combinator
+    Data.Attoparsec.Internal
+    Data.Attoparsec.Internal.Fhthagn
+    Data.Attoparsec.Internal.Types
+    Data.Attoparsec.Number
+
+  ghc-options:          -funbox-strict-fields -Wall -fwarn-tabs -O2
+
+  ghc-options: -Wall
+  if impl(ghc >= 8.0)
+    ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
+  else
+    build-depends: semigroups ^>= 0.18.3, fail ^>= 4.9.0.0
+
+
+test-suite spec
+  type:             exitcode-stdio-1.0
+  default-language: Haskell2010
+  main-is:          Spec.hs
+  hs-source-dirs:
+      test
+    , src
+  ghc-options: -Wall
+
+  cpp-options:
+      -DTEST
+
+  other-modules:
+      Documentation.Haddock.Doc
+      Documentation.Haddock.Parser
+      Documentation.Haddock.Parser.Monad
+      Documentation.Haddock.Parser.Util
+      Documentation.Haddock.Parser.UtilSpec
+      Documentation.Haddock.ParserSpec
+      Documentation.Haddock.Types
+      Documentation.Haddock.Utf8
+      Documentation.Haddock.Utf8Spec
+
+  build-depends:
+      base-compat   ^>= 0.9.3
+    , transformers   >= 0.3.0   && < 0.6
+    , hspec         ^>= 2.4.4
+    , QuickCheck    ^>= 2.10
+
+  -- internal sub-lib
+  build-depends: attoparsec
+
+  -- Versions for the dependencies below are transitively pinned by
+  -- dependency on haddock-library:lib:attoparsec
+  build-depends:
+      base
+    , bytestring
+    , deepseq
+
+  build-tool-depends:
+    hspec-discover:hspec-discover ^>= 2.4.4
+
+source-repository head
+  type:     git
+  subdir:   haddock-library
+  location: https://github.com/haskell/haddock.git
diff --git a/test/golden-test-cases/haddock-library.nix.golden b/test/golden-test-cases/haddock-library.nix.golden
new file mode 100644
--- /dev/null
+++ b/test/golden-test-cases/haddock-library.nix.golden
@@ -0,0 +1,20 @@
+{ mkDerivation, base, base-compat, bytestring, deepseq, fetchurl
+, hspec, hspec-discover, QuickCheck, transformers
+}:
+mkDerivation {
+  pname = "haddock-library";
+  version = "1.4.5";
+  src = fetchurl {
+    url = "http://example.org/";
+    sha256 = "abc";
+  };
+  libraryHaskellDepends = [ base bytestring deepseq transformers ];
+  testHaskellDepends = [
+    base base-compat bytestring deepseq hspec QuickCheck transformers
+  ];
+  testToolDepends = [ hspec-discover ];
+  doHaddock = false;
+  homepage = "http://www.haskell.org/haddock/";
+  description = "Library exposing some functionality of Haddock";
+  license = stdenv.lib.licenses.bsd3;
+}
