diff --git a/cabal2nix.cabal b/cabal2nix.cabal
--- a/cabal2nix.cabal
+++ b/cabal2nix.cabal
@@ -2,10 +2,10 @@
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: d8202a64b33d8fbb627b568af818cd121aecd00f917af6b899cf9b07c48fa55a
+-- hash: 92f9b21ea7d805cee72dd61ac36b18711504bee1d8e06b4dbffb9ade7fab4378
 
 name:           cabal2nix
-version:        2.7.1
+version:        2.7.2
 synopsis:       Convert Cabal files into Nix build instructions.
 description:    Convert Cabal files into Nix build instructions. Users of Nix can install the latest version by running:
                 .
@@ -81,7 +81,7 @@
 maintainer:     Peter Simons <simons@cryp.to>
 license:        BSD3
 license-file:   LICENSE
-tested-with:    GHC > 7.10 && < 8.3
+tested-with:    GHC > 8.2 && < 8.3
 build-type:     Custom
 cabal-version:  >= 1.24
 
diff --git a/src/Cabal2nix.hs b/src/Cabal2nix.hs
--- a/src/Cabal2nix.hs
+++ b/src/Cabal2nix.hs
@@ -151,7 +151,7 @@
   when (isJust optHackageDb) $ hPutStrLn stderr "WARN: HackageDB provided directly; ignoring --hackage-db"
   when (isJust optHackageSnapshot) $ hPutStrLn stderr "WARN: HackageDB provided directly; ignoring --hackage-snapshot"
 
-  pkg <- getPackage' optHpack db $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
+  pkg <- getPackage' optHpack (return db) $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
   processPackage opts pkg
 
 processPackage :: Options -> Package -> IO (Either Doc Derivation)
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
@@ -43,12 +43,11 @@
            -> Source
            -> IO Package
 getPackage optHpack optHackageDB optHackageSnapshot source = do
-  hackageDB <- loadHackageDB optHackageDB optHackageSnapshot
-  getPackage' optHpack hackageDB source
+  getPackage' optHpack (loadHackageDB optHackageDB optHackageSnapshot) source
 
 getPackage' :: Bool
             -- ^ Whether hpack should regenerate the cabal file.
-            -> DB.HackageDB
+            -> IO DB.HackageDB
             -> Source
             -> IO Package
 getPackage' optHpack hackageDB source = do
@@ -57,7 +56,7 @@
 
 fetchOrFromDB :: Bool
               -- ^ Whether hpack should regenerate the cabal file
-              -> DB.HackageDB
+              -> IO DB.HackageDB
               -> Source
               -> IO (Maybe DerivationSource, Bool, Cabal.GenericPackageDescription)
 fetchOrFromDB optHpack hackageDB src
@@ -80,10 +79,11 @@
   dbPath <- maybe DB.hackageTarball return optHackageDB
   DB.readTarball optHackageSnapshot dbPath
 
-fromDB :: DB.HackageDB
+fromDB :: IO DB.HackageDB
        -> String
        -> IO (Maybe DerivationSource, Cabal.GenericPackageDescription)
-fromDB hackageDB pkg = do
+fromDB hackageDBIO pkg = do
+  hackageDB <- hackageDBIO
   vd <- maybe unknownPackageError return (DB.lookup name hackageDB >>= lookupVersion)
   let ds = case DB.tarballSha256 vd of
              Nothing -> Nothing
