diff --git a/cabal2nix.cabal b/cabal2nix.cabal
--- a/cabal2nix.cabal
+++ b/cabal2nix.cabal
@@ -1,5 +1,5 @@
 name:               cabal2nix
-version:            2.10.1
+version:            2.10.2
 synopsis:           Convert Cabal files into Nix build instructions.
 description:
   Convert Cabal files into Nix build instructions. Users of Nix can install the latest
@@ -119,7 +119,7 @@
                     , filepath
                     , hackage-db           >= 2.0.1
                     , hopenssl             >= 2
-                    , hpack                >= 0.26
+                    , hpack                >= 0.29.6
                     , language-nix
                     , lens
                     , optparse-applicative
diff --git a/src/Cabal2nix.hs b/src/Cabal2nix.hs
--- a/src/Cabal2nix.hs
+++ b/src/Cabal2nix.hs
@@ -88,7 +88,7 @@
           <*> option (maybeReader parsePlatform) (long "system" <> help "host system (in either short Nix format or full LLVM style) to use when evaluating the Cabal file" <> value buildPlatform <> showDefaultWith display)
           <*> optional (strOption $ long "subpath" <> metavar "PATH" <> help "Path to Cabal file's directory relative to the URI (default is root directory)")
           <*> optional (option utcTimeReader (long "hackage-snapshot" <> help "hackage snapshot time, ISO format"))
-          <*> pure (\i -> Just (binding # (i, path # [i])))
+          <*> pure (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
           <*> strArgument (metavar "URI")
 
 -- | A parser for the date. Hackage updates happen maybe once or twice a month.
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
@@ -122,6 +122,14 @@
     resolveInHackage i | (i^.ident) `elem` [ unPackageName n | (Dependency n _) <- missingDeps ] = bindNull i
                        | otherwise = binding # (i, path # ["self",i])   -- TODO: "self" shouldn't be hardcoded.
 
+    -- TODO: This is all very confusing. Haskell packages refer to the Nixpkgs
+    -- derivation 'foo' as 'pkgs.foo', because they live in the 'haskellPackages'
+    -- name space -- not on the top level. Therefore, we built our Nixpkgs lookup
+    -- function so that top level names are returned as 'pkgs.foo'. As a result, we
+    -- end up pre-pending that path to all kinds of names all over the place. I
+    -- suppose the correct approach would be to assume that the lookup function
+    -- returns names that live in the top-level and to adapt the code in
+    -- PostProcess.hs et all to that fact.
     goodScopes :: Set [Identifier]
     goodScopes = Set.fromList (map ("pkgs":) [[], ["xorg"], ["xlibs"], ["gnome2"], ["gnome"], ["gnome3"], ["kde4"]])
 
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs
@@ -46,7 +46,7 @@
  | name == "hlibsass" && version >= mkVersion [0,1,5]
                                 = [enable "externalLibsass"]
  | name == "hmatrix"            = [enable "openblas", enable "disable-default-paths"]
- | name == "hslua"              = [enable "system-lua"]
+ | name == "hslua"              = [enable "system-lua", disable "use-pkgconfig"]
  | name == "idris"              = [enable "gmp", enable "ffi", enable "curses", ("execonly", version `withinRange` orLaterVersion (mkVersion [1,1,1])) ]
  | name == "io-streams"         = [enable "NoInteractiveTests"]
  | name == "liquid-fixpoint"    = [enable "build-external"]
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
@@ -38,7 +38,7 @@
 libNixName "crypt"                              = []  -- provided by glibc
 libNixName "crypto"                             = return "openssl"
 libNixName "curses"                             = return "ncurses"
-libNixName "dbusmenu-glib-0.4"                  = return "libdbusmenu-glib"
+libNixName "dbusmenu-glib-0.4"                  = return "libdbusmenu"
 libNixName "dbusmenu-gtk3-0.4"                  = ["libdbusmenu-gtk3", "gtk3"]
 libNixName "dl"                                 = []  -- provided by glibc
 libNixName "fftw3"                              = return "fftw"
@@ -97,6 +97,7 @@
 libNixName "libR"                               = return "R"
 libNixName "libsoup-gnome-2.4"                  = return "libsoup"
 libNixName "libsystemd"                         = return "systemd"
+libNixName "libudev"                            = return "systemd"
 libNixName "libxml-2.0"                         = return "libxml2"
 libNixName "libzip"                             = return "libzip"
 libNixName "libzmq"                             = return "zeromq"
@@ -129,7 +130,6 @@
 libNixName "rt"                                 = [] -- in glibc
 libNixName "rtlsdr"                             = return "rtl-sdr"
 libNixName "ruby1.8"                            = return "ruby"
-libNixName "sane-backends"                      = return "saneBackends"
 libNixName "sass"                               = return "libsass"
 libNixName "sctp"                               = return "lksctp-tools" -- This is linux-specific, we should create a common attribute if we ever add sctp support for other systems.
 libNixName "sdl2"                               = return "SDL2"
@@ -144,6 +144,7 @@
 libNixName "systemd-journal"                    = return "systemd"
 libNixName "tag_c"                              = return "taglib"
 libNixName "taglib_c"                           = return "taglib"
+libNixName "tensorflow"                         = return "libtensorflow"
 libNixName "udev"                               = return "systemd";
 libNixName "uuid"                               = return "libossp_uuid";
 libNixName "wayland-client"                     = return "wayland"
@@ -154,6 +155,7 @@
 libNixName "webkit2gtk-web-extension-4.0"       = return "webkitgtk-web-extension"  -- This package doesn't actually exist in nixpkgs at present.
 libNixName "webkitgtk-3.0"                      = return "webkitgtk24x-gtk3"     -- These are the old APIs, of which 2.4 is the last provider, so map directly to that
 libNixName "X11"                                = return "libX11"
+libNixName "x11"                                = return "xlibsWrapper"
 libNixName "xau"                                = return "libXau"
 libNixName "Xcursor"                            = return "libXcursor"
 libNixName "xerces-c"                           = return "xercesc"
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs
@@ -75,9 +75,9 @@
   , ("Agda >= 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agda25PostInstall)
   , ("alex < 3.1.5",  set (testDepends . tool . contains (pkg "perl")) True)
   , ("alex",  set (executableDepends . tool . contains (self "happy")) True)
-  , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))                                                                                                      , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
+  , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
   , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"])))
-  , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))                                                                                                      , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
+  , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
   , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
   , ("Cabal", set doCheck False) -- test suite doesn't work in Nix
   , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [self "mtl", self "parsec"]))) -- https://github.com/haskell/cabal/issues/5391
@@ -117,8 +117,8 @@
   , ("holy-project", set doCheck False)         -- attempts to access the network
   , ("hoogle", set testTarget "--test-option=--no-net")
   , ("hsignal < 0.2.7.4", set phaseOverrides "prePatch = \"rm -v Setup.lhs\";") -- https://github.com/amcphail/hsignal/issues/1
-  , ("hslua < 0.9.3", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_1")))
-  , ("hslua >= 0.9.3", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_3")))
+  , ("hslua < 0.9.3", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_1")))
+  , ("hslua >= 0.9.3", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_3")))
   , ("hspec-core >= 2.4.4", hspecCoreOverrides)
   , ("http-client", set doCheck False)          -- attempts to access the network
   , ("http-client-openssl >= 0.2.0.1", set doCheck False) -- attempts to access the network
@@ -142,6 +142,8 @@
   , ("pandoc", set jailbreak False) -- jailbreak-cabal break the build
   , ("pandoc-citeproc", set doCheck False) -- https://github.com/jgm/pandoc-citeproc/issues/172
   , ("purescript", set doCheck False) -- test suite doesn't cope with Nix build env
+  , ("proto-lens-protobuf-types", set (libraryDepends . tool . contains (pkg "protobuf")) True)
+  , ("proto-lens-protoc", set (libraryDepends . tool . contains (pkg "protobuf")) True)
   , ("qtah-cpp-qt5", set (libraryDepends . system . contains (bind "pkgs.qt5.qtbase")) True)
   , ("qtah-qt5", set (libraryDepends . tool . contains (bind "pkgs.qt5.qtbase")) True)
   , ("readline", over (libraryDepends . system) (Set.union (pkgs ["readline", "ncurses"])))
@@ -155,10 +157,11 @@
   , ("target", set (testDepends . system . contains (pkg "z3")) True)
   , ("terminfo", set (libraryDepends . system . contains (pkg "ncurses")) True)
   , ("text", set doCheck False)         -- break infinite recursion
+  , ("tensorflow-proto", set (libraryDepends . tool . contains (pkg "protobuf")) True)
   , ("thyme", set (libraryDepends . tool . contains (self "cpphs")) True) -- required on Darwin
   , ("twilio", set doCheck False)         -- attempts to access the network
   , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";")
-  , ("udev", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))                                                                                                      , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
+  , ("udev", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
   , ("webkitgtk3", webkitgtk24xHook)   -- https://github.com/haskell-gi/haskell-gi/issues/36
   , ("webkitgtk3-javascriptcore", webkitgtk24xHook)   -- https://github.com/haskell-gi/haskell-gi/issues/36
   , ("websockets", set doCheck False)   -- https://github.com/jaspervdj/websockets/issues/104
@@ -187,10 +190,18 @@
     is = map (review ident) (splitOn "." s)
     i = last is
 
+-- | @replace old new bset@ replaces the Nix binding @old@ with @new@ in the
+-- set of bindings @bset@. If @old@ is not found in @bset@, then the function
+-- fails with an 'error'.
 replace :: Binding -> Binding -> Set Binding -> Set Binding
-replace old new bs = if old `Set.member` bs then Set.insert new (Set.delete old bs) else bs
+replace old new bs
+  | old `Set.member` bs = Set.insert new (Set.delete old bs)
+  | otherwise           = error (unwords [ "post-process: cannot replace name binding"
+                                         , show old, "by", show new
+                                         , "because it's not found in set"
+                                         , show bs
+                                         ])
 
--- TODO: I need to figure out how to conveniently replace a binding in a set.
 gtk3Hook :: Derivation -> Derivation    -- https://github.com/NixOS/cabal2nix/issues/145
 gtk3Hook = set (libraryDepends . pkgconfig . contains (pkg "gtk3")) True
          . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "gtk3"))
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
@@ -183,13 +183,17 @@
                    -> FilePath -> MaybeT IO (Bool, Cabal.GenericPackageDescription)
 cabalFromDirectory True dir = hpackDirectory dir
 cabalFromDirectory False dir = do
-  cabals <- liftIO $ getDirectoryContents dir >>= filterM doesFileExist . map (dir </>) . filter (".cabal" `isSuffixOf`)
-  case cabals of
-    [] -> do
-      liftIO $ hPutStrLn stderr "*** found zero cabal files. Trying hpack..."
+  useHpack <- liftIO $ doesFileExist (dir </> "package.yaml")
+  if useHpack
+    then do
+      liftIO $ hPutStrLn stderr "*** found package.yaml. Using hpack..."
       hpackDirectory dir
-    [cabalFile] -> (,) False <$> cabalFromFile True cabalFile
-    _       -> liftIO $ fail ("*** found more than one cabal file (" ++ show cabals ++ "). Exiting.")
+    else do
+      cabals <- liftIO $ getDirectoryContents dir >>= filterM doesFileExist . map (dir </>) . filter (".cabal" `isSuffixOf`)
+      case cabals of
+        [] -> fail "*** Found neither a .cabal file nor package.yaml. Exiting."
+        [cabalFile] -> (,) False <$> cabalFromFile True cabalFile
+        _ -> liftIO $ fail ("*** found more than one cabal file (" ++ show cabals ++ "). Exiting.")
 
 handleIO :: (Exception.IOException -> IO a) -> IO a -> IO a
 handleIO = Exception.handle
@@ -199,7 +203,10 @@
 
 hpackDirectory :: FilePath -> MaybeT IO (Bool, Cabal.GenericPackageDescription)
 hpackDirectory dir = do
-  mPackage <- liftIO $ Hpack.readPackageConfig Hpack.defaultDecodeOptions {Hpack.decodeOptionsTarget = dir </> Hpack.packageConfig}
+  mPackage <- liftIO $ Hpack.readPackageConfig Hpack.defaultDecodeOptions {
+      Hpack.decodeOptionsProgramName = Hpack.ProgramName "cabal2nix"
+    , Hpack.decodeOptionsTarget = dir </> Hpack.packageConfig
+    }
   case mPackage of
     Left err -> liftIO $ hPutStrLn stderr ("*** hpack error: " ++ show err ++ ". Exiting.") >> exitFailure
     Right r -> do
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -46,7 +46,7 @@
       cabal2nix :: GenericPackageDescription -> Derivation
       cabal2nix gpd = fromGenericPackageDescription
                          (const True)
-                         (\i -> Just (binding # (i, path # [i])))
+                         (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
                          (Platform X86_64 Linux)
                          (unknownCompilerInfo (CompilerId GHC (mkVersion [8,2])) NoAbiTag)
                          (configureCabalFlags (packageId gpd))
diff --git a/test/golden-test-cases/opencv.cabal b/test/golden-test-cases/opencv.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden-test-cases/opencv.cabal
@@ -0,0 +1,263 @@
+name:          opencv
+version:       0.0.2.1
+homepage:      https://github.com/LumiGuide/haskell-opencv
+bug-reports:   https://github.com/LumiGuide/haskell-opencv/issues
+license:       BSD3
+license-file:  LICENSE
+author:        Roel van Dijk <roel@lambdacube.nl>, Bas van Dijk <v.dijk.bas@gmail.com>
+maintainer:    Roel van Dijk <roel@lambdacube.nl>, Bas van Dijk <v.dijk.bas@gmail.com>
+build-type:    Custom
+cabal-version: >=1.23
+category:      AI, Graphics
+synopsis:      Haskell binding to OpenCV-3.x
+description:   <<https://raw.githubusercontent.com/LumiGuide/haskell-opencv/master/data/haskell-opencv-logo-200x82.png>>
+               .
+               This is a Haskell library providing a binding to OpenCV-3.x.
+               It binds directly with the C++ API using the @inline-c@ Haskell library.
+               .
+               The library is far from complete but the framework is there to easily
+               bind missing functionality.
+               .
+               Note that the OpenCV contrib modules are provided by
+               <http://hackage.haskell.org/package/opencv-extra opencv-extra>.
+               .
+               Make sure to checkout the
+               <https://github.com/LumiGuide/haskell-opencv/tree/master/opencv-examples opencv-examples>.
+
+extra-source-files:
+    CHANGELOG.md
+    data/*.png
+    data/*.jpg
+    data/*.mp4
+    data/*.xml
+
+extra-doc-files:
+    doc/generated/*.png
+    doc/generated/examples/*.png
+    doc/generated/examples/*.gif
+    doc/color_conversions.png
+
+source-repository head
+  type:     git
+  location: git://github.com/LumiGuide/haskell-opencv.git
+  subdir:   opencv
+
+flag internal-documentation
+    description: Enables documentation generation for internal modules.
+    default: False
+    manual: True
+
+custom-setup
+    setup-depends: base, Cabal >= 1.23
+
+library
+    hs-source-dirs: src
+    include-dirs: include
+    install-includes:
+        haskell_opencv_matx_typedefs.hpp
+        hsc_macros.hpp
+        namespace.hpp
+        orb.hpp
+        simple_blob_detector.hpp
+        termcriteria.hpp
+        video_motion_analysis.hpp
+
+    cc-options: -Wall -std=c++11
+    ghc-options: -Wall -fwarn-incomplete-patterns -funbox-strict-fields
+    if flag(internal-documentation)
+        cpp-options: -DENABLE_INTERNAL_DOCUMENTATION
+
+    build-depends:
+        aeson             >= 0.9.0.1
+      , base              >= 4.8     && <5
+      , base64-bytestring >= 1.0.0.1
+      , bindings-DSL      >= 1.0.23
+      , bytestring        >= 0.10.6
+      , containers        >= 0.5.6.2
+      , data-default      >= 0.7.1.1
+      , deepseq           >= 1.4.1.1
+      , inline-c          >= 0.6
+      , inline-c-cpp      >= 0.2.1
+      , JuicyPixels       >= 3.2.8.1
+      , linear            >= 1.20.4
+      , primitive         >= 0.6.1
+      , repa              >= 3.4.0.2
+      , template-haskell  >= 2.10
+      , text              >= 1.2.2.1
+      , transformers      >= 0.4.2
+      , vector            >= 0.11
+
+    exposed-modules:
+        OpenCV
+        OpenCV.Calib3d
+        OpenCV.Core.ArrayOps
+        OpenCV.Core.Types
+        OpenCV.Core.Types.Mat
+        OpenCV.Core.Types.Mat.HMat
+        OpenCV.Core.Types.Mat.Repa
+        OpenCV.Core.Types.Matx
+        OpenCV.Core.Types.Point
+        OpenCV.Core.Types.Rect
+        OpenCV.Core.Types.Size
+        OpenCV.Core.Types.Vec
+        OpenCV.Exception
+        OpenCV.Features2d
+        OpenCV.HighGui
+        OpenCV.ImgCodecs
+        OpenCV.ImgProc.ColorMaps
+        OpenCV.ImgProc.Drawing
+        OpenCV.ImgProc.FeatureDetection
+        OpenCV.ImgProc.GeometricImgTransform
+        OpenCV.ImgProc.ImgFiltering
+        OpenCV.ImgProc.MiscImgTransform
+        OpenCV.ImgProc.MiscImgTransform.ColorCodes
+        OpenCV.ImgProc.ObjectDetection
+        OpenCV.ImgProc.StructuralAnalysis
+        OpenCV.ImgProc.Types
+        OpenCV.ImgProc.CascadeClassifier
+        OpenCV.JSON
+        OpenCV.Photo
+        OpenCV.TypeLevel
+        OpenCV.Unsafe
+        OpenCV.Video
+        OpenCV.Video.MotionAnalysis
+        OpenCV.VideoIO.Types
+        OpenCV.VideoIO.VideoCapture
+        OpenCV.VideoIO.VideoWriter
+
+        OpenCV.Internal
+        OpenCV.Internal.Mutable
+        OpenCV.Internal.C.Inline
+        OpenCV.Internal.C.PlacementNew
+        OpenCV.Internal.C.PlacementNew.TH
+        OpenCV.Internal.C.Types
+        OpenCV.Internal.Calib3d.Constants
+        OpenCV.Internal.Core.ArrayOps
+        OpenCV.Internal.Core.Types
+        OpenCV.Internal.Core.Types.Constants
+        OpenCV.Internal.Core.Types.Mat
+        OpenCV.Internal.Core.Types.Mat.Depth
+        OpenCV.Internal.Core.Types.Mat.HMat
+        OpenCV.Internal.Core.Types.Mat.Marshal
+        OpenCV.Internal.Core.Types.Mat.ToFrom
+        OpenCV.Internal.Core.Types.Matx
+        OpenCV.Internal.Core.Types.Matx.TH
+        OpenCV.Internal.Core.Types.Point
+        OpenCV.Internal.Core.Types.Point.TH
+        OpenCV.Internal.Core.Types.Rect
+        OpenCV.Internal.Core.Types.Rect.TH
+        OpenCV.Internal.Core.Types.Size
+        OpenCV.Internal.Core.Types.Size.TH
+        OpenCV.Internal.Core.Types.Vec
+        OpenCV.Internal.Core.Types.Vec.TH
+        OpenCV.Internal.Exception
+        OpenCV.Internal.ImgCodecs
+        OpenCV.Internal.ImgProc.MiscImgTransform
+        OpenCV.Internal.ImgProc.MiscImgTransform.TypeLevel
+        OpenCV.Internal.ImgProc.MiscImgTransform.ColorCodes
+        OpenCV.Internal.ImgProc.Types
+        OpenCV.Internal.Photo.Constants
+        OpenCV.Internal.VideoIO.Constants
+        OpenCV.Internal.VideoIO.Types
+        OpenCV.Juicy
+
+    default-extensions:
+        BangPatterns
+        DataKinds
+        FlexibleContexts
+        FlexibleInstances
+        LambdaCase
+        OverloadedStrings
+        PackageImports
+        PolyKinds
+        ScopedTypeVariables
+        TupleSections
+        TypeFamilies
+        TypeOperators
+
+    default-language:   Haskell2010
+    pkgconfig-depends:  opencv >= 3.0.0
+    extra-libraries:    stdc++
+
+test-suite doc-images-opencv
+    type: exitcode-stdio-1.0
+    hs-source-dirs: doc
+    main-is: images.hs
+    other-modules:
+        ExampleExtractor
+        Language.Haskell.Meta.Syntax.Translate
+    default-language: Haskell2010
+    ghc-options: -Wall -fwarn-incomplete-patterns -threaded -funbox-strict-fields -rtsopts
+    build-depends:
+        base              >= 4.8 && < 5
+      , bytestring        >= 0.10.6
+      , containers        >= 0.5.6.2
+      , data-default      >= 0.7.1.1
+      , directory         >= 1.2.2
+      , Glob              >= 0.9
+      , haskell-src-exts  >= 1.18.2
+      , JuicyPixels       >= 3.2.8.1
+      , linear            >= 1.20.4
+      , opencv
+      , primitive         >= 0.6.1
+      , template-haskell  >= 2.10
+      , text              >= 1.2.2.1
+      , transformers      >= 0.4.2
+      , vector            >= 0.11
+
+    default-extensions:
+        BangPatterns
+        DataKinds
+        LambdaCase
+        OverloadedStrings
+        PackageImports
+        PolyKinds
+        ScopedTypeVariables
+        TupleSections
+        TypeFamilies
+        TypeOperators
+
+test-suite test-opencv
+    type:             exitcode-stdio-1.0
+    hs-source-dirs:   test
+    main-is:          test.hs
+    default-language: Haskell2010
+    ghc-options:      -Wall -fwarn-incomplete-patterns -threaded -funbox-strict-fields -rtsopts
+    build-depends:
+        base              >= 4.8 && < 5
+      , bytestring        >= 0.10.6
+      , lens              >= 4.13
+      , linear            >= 1.20.4
+      , opencv
+      , QuickCheck        >= 2.10.1
+      , repa              >= 3.4.0.2
+      , tasty             >= 0.11.0.2
+      , tasty-hunit       >= 0.9.2
+      , tasty-quickcheck  >= 0.8.4
+      , transformers      >= 0.4.2
+      , vector            >= 0.11
+
+    default-extensions:
+        DataKinds
+        FlexibleContexts
+        PackageImports
+        RankNTypes
+        ScopedTypeVariables
+        TypeOperators
+
+benchmark bench-opencv
+    type:             exitcode-stdio-1.0
+    hs-source-dirs:   bench
+    main-is:          bench.hs
+    default-language: Haskell2010
+    ghc-options: -Wall -fwarn-incomplete-patterns -threaded -funbox-strict-fields -rtsopts
+    build-depends:
+        base              >= 4.8 && < 5
+      , bytestring        >= 0.10.6
+      , criterion         >= 1.1.1
+      , opencv
+      , repa              >= 3.4.0.2
+
+    default-extensions:
+        DataKinds
+        PackageImports
diff --git a/test/golden-test-cases/opencv.nix.golden b/test/golden-test-cases/opencv.nix.golden
new file mode 100644
--- /dev/null
+++ b/test/golden-test-cases/opencv.nix.golden
@@ -0,0 +1,33 @@
+{ mkDerivation, aeson, base, base64-bytestring, bindings-DSL
+, bytestring, Cabal, containers, criterion, data-default, deepseq
+, directory, Glob, haskell-src-exts, inline-c, inline-c-cpp
+, JuicyPixels, lens, linear, opencv3, primitive, QuickCheck, repa
+, stdenv, tasty, tasty-hunit, tasty-quickcheck, template-haskell
+, text, transformers, vector
+}:
+mkDerivation {
+  pname = "opencv";
+  version = "0.0.2.1";
+  sha256 = "deadbeef";
+  configureFlags = [
+    "--with-gcc=${stdenv.cc}/bin/c++" "--with-ld=${stdenv.cc}/bin/c++"
+  ];
+  setupHaskellDepends = [ base Cabal ];
+  libraryHaskellDepends = [
+    aeson base base64-bytestring bindings-DSL bytestring containers
+    data-default deepseq inline-c inline-c-cpp JuicyPixels linear
+    primitive repa template-haskell text transformers vector
+  ];
+  libraryPkgconfigDepends = [ opencv3 ];
+  testHaskellDepends = [
+    base bytestring containers data-default directory Glob
+    haskell-src-exts JuicyPixels lens linear primitive QuickCheck repa
+    tasty tasty-hunit tasty-quickcheck template-haskell text
+    transformers vector
+  ];
+  benchmarkHaskellDepends = [ base bytestring criterion repa ];
+  hardeningDisable = [ "bindnow" ];
+  homepage = "https://github.com/LumiGuide/haskell-opencv";
+  description = "Haskell binding to OpenCV-3.x";
+  license = stdenv.lib.licenses.bsd3;
+}
