diff --git a/cabal-sort.cabal b/cabal-sort.cabal
--- a/cabal-sort.cabal
+++ b/cabal-sort.cabal
@@ -1,6 +1,6 @@
 Cabal-Version:    2.2
 Name:             cabal-sort
-Version:          0.0.5.5
+Version:          0.1
 License:          BSD-3-Clause
 License-File:     LICENSE
 Author:           Henning Thielemann <haskell@henning-thielemann.de>
@@ -81,7 +81,7 @@
   .
   Related packages: @rpmbuild-order@
 Tested-With:       GHC==6.10.4, GHC==6.12.3
-Tested-With:       GHC==8.0.2
+Tested-With:       GHC==8.0.2, GHC==8.6.5
 Build-Type:        Simple
 Source-Repository head
   type:     darcs
@@ -90,12 +90,12 @@
 Source-Repository this
   type:     darcs
   location: http://code.haskell.org/~thielema/cabal-sort/
-  tag:      0.0.5.5
+  tag:      0.1
 
 
 Executable cabal-sort
   Build-Depends:
-    Cabal >=1.6 && <2,
+    Cabal >=3.8 && <3.11,
     fgl >=5.4.2 && <5.9,
     directory >=1 && <1.4,
     filepath >=1.1 && <1.5,
@@ -111,13 +111,14 @@
 
 Executable ghc-pkg-dep
   Build-Depends:
-    Cabal >=1.6 && <2,
+    Cabal >=1.22 && <3.11,
     process >=1.0 && <1.7,
     containers >=0.2 && <0.7,
     explicit-exception >=0.1.6 && <0.3,
-    utility-ht >=0.0.5 && <0.1,
+    non-empty >=0.3.3 && <0.4,
+    utility-ht >=0.0.12 && <0.1,
     transformers >=0.2 && <0.7,
-    bytestring >=0.9.1 && <0.12,
+    bytestring >=0.9.1 && <0.13,
     base >=2 && <5
 
   GHC-Options:      -Wall
diff --git a/src/CabalSort.hs b/src/CabalSort.hs
--- a/src/CabalSort.hs
+++ b/src/CabalSort.hs
@@ -1,14 +1,14 @@
 module Main where
 
 import qualified Distribution.PackageDescription as P
-import Distribution.PackageDescription
-         (GenericPackageDescription, package, packageDescription, )
-import Distribution.PackageDescription.Parse (readPackageDescription, )
-import Distribution.Package
-         (Dependency(Dependency), PackageName(PackageName), pkgName, )
-
 import qualified Distribution.Verbosity as Verbosity
 import qualified Distribution.ReadE as ReadE
+import Distribution.Simple.PackageDescription (readGenericPackageDescription)
+import Distribution.PackageDescription
+         (GenericPackageDescription, package, packageDescription)
+import Distribution.Types.Dependency (Dependency(Dependency))
+import Distribution.Types.PackageName (PackageName, unPackageName)
+import Distribution.Types.PackageId (pkgName)
 
 import System.Console.GetOpt
           (getOpt, ArgOrder(..), OptDescr(..), ArgDescr(..), usageInfo, )
@@ -47,7 +47,7 @@
                        optParallel = False,
                        optMakefile = False,
                        optBuilddir = ".",
-                       optInstall = "cabal install"})
+                       optInstall = "cabal v1-install"})
                opts
       when (optHelp flags)
          (Trans.lift $
@@ -95,7 +95,7 @@
             fmap (\select -> flags{optInfo = select}) $
             case str of
                "name" -> Exc.Success
-                            (getPkgName . pkgName . package .
+                            (unPackageName . pkgName . package .
                              packageDescription . description)
                "path" -> Exc.Success location
                "dir"  -> Exc.Success (FilePath.takeDirectory . location)
@@ -137,15 +137,17 @@
 sortCabalFiles flags cabalPaths =
    do pkgDescs <-
          Trans.lift $
-         mapM (readPackageDescription (optVerbosity flags)) cabalPaths
+         mapM (readGenericPackageDescription (optVerbosity flags)) cabalPaths
       when (optVerbosity flags >= Verbosity.verbose) $
          Trans.lift $
          flip mapM_ pkgDescs $ \pkgDesc -> do
             putStrLn
-               ((getPkgName . pkgName . package . packageDescription $ pkgDesc) ++ ":")
+               ((unPackageName . pkgName . package . packageDescription $
+                  pkgDesc)
+                 ++ ":")
             let deps =
                    Set.toAscList $ Set.fromList $
-                   map (getPkgName . depName) $
+                   map (unPackageName . depName) $
                    allDependencies pkgDesc
             flip mapM_ deps $ \dep ->
                putStrLn $ "  " ++ dep
@@ -247,7 +249,7 @@
 
 allDependencies :: GenericPackageDescription -> [Dependency]
 allDependencies pkg =
-   P.buildDepends (packageDescription pkg) ++
+   P.allBuildDepends (packageDescription pkg) ++
    maybe [] (concatMap snd . flattenCondTree) (P.condLibrary pkg) ++
    concatMap (concatMap snd . flattenCondTree . snd) (P.condExecutables pkg)
 
@@ -255,13 +257,10 @@
 flattenCondTree tree =
    (P.condTreeData tree, P.condTreeConstraints tree) :
    concatMap
-      (\(_, thenBranch, elseBranch) ->
+      (\(P.CondBranch _ thenBranch elseBranch) ->
          flattenCondTree thenBranch ++
          maybe [] flattenCondTree elseBranch)
       (P.condTreeComponents tree)
 
 depName :: Dependency -> PackageName
-depName (Dependency name _) = name
-
-getPkgName :: PackageName -> String
-getPkgName (PackageName name) = name
+depName (Dependency name _ _) = name
diff --git a/src/GhcPkgDep.hs b/src/GhcPkgDep.hs
--- a/src/GhcPkgDep.hs
+++ b/src/GhcPkgDep.hs
@@ -17,10 +17,10 @@
 import qualified Control.Monad.Trans.State as State
 import qualified Control.Monad.Trans.Class as Trans
 
-import qualified Data.Set as Set
-
 import qualified Data.ByteString.Char8 as B
-
+import qualified Data.Foldable as Fold
+import qualified Data.Set as Set
+import qualified Data.NonEmpty as NonEmpty
 import qualified Data.List.HT as ListHT
 import qualified Data.List as List
 import qualified Data.Char as Char
@@ -68,7 +68,6 @@
       optUser = False,
       optGlobal = False,
       optShowVersions = False,
-      -- ToDo: how about using PackageIndex?
       optPkgCmd = "ghc-pkg"
    }
 
@@ -128,8 +127,9 @@
               allDeps <- mapM (getAllDependencies flags False) deps
               let strippedName = fromMaybe name $ do
                      guard $ not $ optShowVersions flags
-                     Pkg.PackageName pname <-
-                        fmap Pkg.pkgName $ DistText.simpleParse name
+                     pname <-
+                        fmap (Pkg.unPackageName . Pkg.pkgName) $
+                        DistText.simpleParse name
                      return pname
               return $ concat allDeps ++ [strippedName])
           (\errTxt ->
@@ -172,7 +172,7 @@
          since it contains an underscore.
          -}
          return $
-            map stripHashId $
+            map stripHashAndPrivateLibName $
             filter (flip notElem ["depends:", "builtin_rts"]) names
       [] -> return []
       _ -> Exc.throwT $
@@ -182,15 +182,14 @@
                 then "\n" ++ B.unpack txt
                 else ""
 
-stripHashId :: PkgName -> PkgName
-stripHashId name =
-   (\parts ->
-      let lastPart = last parts
-      in  if (not $ null $ drop 15 lastPart) &&
-             all Char.isHexDigit lastPart
-            then List.intercalate "-" $ init parts
-            else name)
+stripHashAndPrivateLibName :: PkgName -> PkgName
+stripHashAndPrivateLibName =
+   (List.intercalate "-" . NonEmpty.flatten .
+      NonEmpty.mapTail (ListHT.takeUntil isVersionNumber))
    .
-   ListHT.chop ('-'==)
-   $
-   name
+   NonEmpty.chop ('-'==)
+
+isVersionNumber :: String -> Bool
+isVersionNumber =
+   Fold.all (\component -> not (null component) && all Char.isDigit component) .
+   NonEmpty.chop ('.'==)
