diff --git a/Setup.lhs b/Setup.lhs
new file mode 100644
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,3 @@
+#!/usr/bin/env runhaskell
+> import Distribution.Simple
+> main = defaultMain
diff --git a/driver/Main.hs b/driver/Main.hs
new file mode 100644
--- /dev/null
+++ b/driver/Main.hs
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import qualified Hpack.Dhall
+
+main :: IO ()
+main = Hpack.Dhall.main
diff --git a/hpack-dhall.cabal b/hpack-dhall.cabal
new file mode 100644
--- /dev/null
+++ b/hpack-dhall.cabal
@@ -0,0 +1,66 @@
+-- This file has been generated from package.yaml by hpack version 0.23.0.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: c298d477b6c09e70c97fdc47ae58b23f965424ab7ecd301c4ab4372a2851cbe7
+
+name:           hpack-dhall
+version:        0.1.0
+synopsis:       Dhall support for Hpack
+description:    This package allows you to use the Dhall configuration language to specify
+                Haskell packages.
+category:       Development
+homepage:       https://github.com/sol/hpack-dhall#readme
+bug-reports:    https://github.com/sol/hpack-dhall/issues
+license:        PublicDomain
+build-type:     Simple
+cabal-version:  >= 1.10
+
+source-repository head
+  type: git
+  location: https://github.com/sol/hpack-dhall
+
+executable hpack-dhall
+  main-is: Main.hs
+  other-modules:
+      Hpack.Dhall
+      Paths_hpack_dhall
+  hs-source-dirs:
+      src
+      driver
+  ghc-options: -Wall
+  build-depends:
+      aeson
+    , base ==4.*
+    , dhall
+    , dhall-json
+    , hpack >=0.23.0
+    , text
+    , transformers
+    , trifecta
+  default-language: Haskell2010
+
+test-suite spec
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  other-modules:
+      Hpack.Dhall
+      Hpack.DhallSpec
+      Paths_hpack_dhall
+  hs-source-dirs:
+      src
+      test
+  ghc-options: -Wall
+  build-depends:
+      aeson
+    , base ==4.*
+    , dhall
+    , dhall-json
+    , hpack >=0.23.0
+    , hspec ==2.*
+    , interpolate
+    , mockery
+    , text
+    , transformers
+    , trifecta
+  default-language: Haskell2010
diff --git a/src/Hpack/Dhall.hs b/src/Hpack/Dhall.hs
new file mode 100644
--- /dev/null
+++ b/src/Hpack/Dhall.hs
@@ -0,0 +1,33 @@
+{-# LANGUAGE NoMonomorphismRestriction #-}
+module Hpack.Dhall where
+
+import           Control.Monad.Trans.Except
+import           Control.Monad.IO.Class
+import           Data.Bifunctor
+import           Data.Aeson
+import qualified Data.Text.Lazy.IO as LT
+import qualified Data.Text as T
+import           Data.Text.Encoding (encodeUtf8)
+import           Text.Trifecta.Delta (Delta(..))
+import qualified Dhall.Parser
+import qualified Dhall.Import
+import qualified Dhall.TypeCheck
+import qualified Dhall.JSON
+
+import qualified Hpack
+
+packageConfig :: FilePath
+packageConfig = "package.dhall"
+
+readDhall :: FilePath -> IO (Either String Value)
+readDhall file = runExceptT $ do
+  expr <- readInput >>= parseExpr >>= liftIO . Dhall.Import.load
+  _ <- liftResult $ Dhall.TypeCheck.typeOf expr
+  liftResult $ Dhall.JSON.dhallToJSON expr
+  where
+    readInput = liftIO (LT.readFile file)
+    parseExpr = liftResult . Dhall.Parser.exprFromText (Directed (encodeUtf8 $ T.pack file) 0 0 0 0)
+    liftResult = ExceptT . return . first show
+
+main :: IO ()
+main = Hpack.mainWith packageConfig readDhall
diff --git a/test/Hpack/DhallSpec.hs b/test/Hpack/DhallSpec.hs
new file mode 100644
--- /dev/null
+++ b/test/Hpack/DhallSpec.hs
@@ -0,0 +1,36 @@
+{-# LANGUAGE QuasiQuotes #-}
+module Hpack.DhallSpec (spec) where
+
+import           Test.Hspec
+import           Test.Mockery.Directory
+import           Data.String.Interpolate
+import           Data.String.Interpolate.Util
+
+import           Data.Version (showVersion)
+import qualified Hpack
+
+import           Hpack.Dhall
+
+spec :: Spec
+spec = do
+  describe "main" $ do
+    it "generates cabal files" $ do
+      inTempDirectory $ do
+        writeFile packageConfig [i|
+        {
+          name = "foo"
+        }
+        |]
+        main
+        readFile "foo.cabal" `shouldReturn` unindent [i|
+        -- This file has been generated from package.dhall by hpack version #{showVersion Hpack.version}.
+        --
+        -- see: https://github.com/sol/hpack
+        --
+        -- hash: 19abf59677a84e0a8a49435b80f42f6007f6cdacd2b09c43514ab2b46d6c5927
+
+        name:           foo
+        version:        0.0.0
+        build-type:     Simple
+        cabal-version:  >= 1.10
+        |]
diff --git a/test/Spec.hs b/test/Spec.hs
new file mode 100644
--- /dev/null
+++ b/test/Spec.hs
@@ -0,0 +1,1 @@
+{-# OPTIONS_GHC -fforce-recomp -F -pgmF hspec-discover #-}
