diff --git a/cabal2nix.cabal b/cabal2nix.cabal
--- a/cabal2nix.cabal
+++ b/cabal2nix.cabal
@@ -3,11 +3,13 @@
 -- see: https://github.com/sol/hpack
 
 name:           cabal2nix
-version:        2.0
+version:        2.0.1
 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:
+                .
                 > nix-env -i cabal2nix
 category:       Distribution, Nix
+stability:      stable
 homepage:       https://github.com/nixos/cabal2nix#readme
 bug-reports:    https://github.com/nixos/cabal2nix/issues
 author:         Peter Simons,
@@ -68,7 +70,7 @@
       src
   ghc-options: -Wall
   build-depends:
-      aeson
+      aeson < 1
     , ansi-wl-pprint
     , base < 5
     , bytestring
@@ -115,7 +117,7 @@
       cabal2nix
   ghc-options: -Wall
   build-depends:
-      aeson
+      aeson < 1
     , ansi-wl-pprint
     , base < 5
     , bytestring
@@ -147,7 +149,7 @@
       hackage2nix
   ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
   build-depends:
-      aeson
+      aeson < 1
     , ansi-wl-pprint
     , base < 5
     , bytestring
diff --git a/cabal2nix/Main.hs b/cabal2nix/Main.hs
--- a/cabal2nix/Main.hs
+++ b/cabal2nix/Main.hs
@@ -6,7 +6,9 @@
 import Control.Exception ( bracket )
 import Control.Lens
 import Data.Maybe ( fromMaybe )
+import Data.Monoid ( (<>) )
 import qualified Data.Set as Set
+import Data.String
 import qualified Distribution.Compat.ReadP as P
 import Distribution.Compiler
 import Distribution.Nixpkgs.Fetch
@@ -130,7 +132,7 @@
               & metaSection.maintainers .~ Set.fromList (map (review ident) optMaintainer)
 --            & metaSection.platforms .~ Set.fromList optPlatform
               & doCheck &&~ optDoCheck
-              & extraFunctionArgs %~ Set.union (Set.fromList ("stdenv":map (review ident) optExtraArgs))
+              & extraFunctionArgs %~ Set.union (Set.fromList ("inherit stdenv":map (fromString . ("inherit " ++)) optExtraArgs))
 
       shell :: Doc
       shell = vcat
diff --git a/hackage2nix/Main.hs b/hackage2nix/Main.hs
--- a/hackage2nix/Main.hs
+++ b/hackage2nix/Main.hs
@@ -82,7 +82,7 @@
             . Map.delete "som"                  -- TODO: https://github.com/NixOS/cabal2nix/issues/164
             . Map.delete "type"                 -- TODO: https://github.com/NixOS/cabal2nix/issues/163
   hackage <- fixup <$> readHackage hackageRepository
-  snapshots <- runParIO (readLTSHaskell ltsHaskellRepository)
+  lts <- readLTSHaskell ltsHaskellRepository
   nightly <- readStackageNightly stackageNightlyRepository
   let
       config :: Configuration
@@ -114,7 +114,7 @@
                           [ Map.singleton name (Set.singleton (resolveConstraint c hackage)) | c@(Dependency name _) <- extraPackages config ]
 
       stackagePackageSet :: Map PackageName (Map Version Spec)
-      stackagePackageSet = Map.fromListWith (Map.unionWith mergeSpecs) [ (n, Map.singleton (Stackage.version spec) spec) | snapshot <- nightly:snapshots, (n, spec) <- Map.toList (packages snapshot) ]
+      stackagePackageSet = Map.fromListWith (Map.unionWith mergeSpecs) [ (n, Map.singleton (Stackage.version spec) spec) | snapshot <- [nightly,lts], (n, spec) <- Map.toList (packages snapshot) ]
 
       db :: PackageMultiSet
       db = Map.unionsWith Set.union [ Map.map Set.singleton generatedDefaultPackageSet
@@ -171,7 +171,7 @@
                   & metaSection.hydraPlatforms %~ (if isInDefaultPackageSet then id else const Set.empty)
 
           overrides :: Doc
-          overrides = fcat $ punctuate space [ disp b <> semi | b <- Set.toList (view (dependencies . each) drv), not (isFromHackage b) ]
+          overrides = fcat $ punctuate space [ disp b <> semi | b <- Set.toList ((view (dependencies . each) drv) `Set.union` view extraFunctionArgs drv), not (isFromHackage b) ]
       return $ render $ nest 2 $
         hang (doubleQuotes (text  attr) <+> equals <+> text "callPackage") 2 (parens (pPrint drv)) <+> (braces overrides <> semi)
 
@@ -187,14 +187,14 @@
     mapM_ (\pkg -> hPutStrLn h pkg >> hPutStrLn h "") pkgs
     hPutStrLn h "}"
 
-  void $ runParIO $ flip parMapM snapshots $ \Snapshot {..} -> liftIO $ do
+  forM_ [lts] $ \Snapshot {..} -> liftIO $ do
      let allPackages :: PackageSet
          allPackages = Map.difference
                          (Map.fromList [ (name, Stackage.version spec) | (name, spec) <- Map.toList packages ] `Map.union` generatedDefaultPackageSet)
                          corePackages'
 
          ltsConfigFile :: FilePath
-         ltsConfigFile = nixpkgsRepository </> "pkgs/development/haskell-modules/configuration-" ++ show (pPrint snapshot) ++ ".nix"
+         ltsConfigFile = nixpkgsRepository </> "pkgs/development/haskell-modules/configuration-lts.nix"
 
          corePackages' :: PackageSet
          corePackages' = corePackages `Map.union` Map.fromList [("Cabal", Version [] []), ("rts", Version [] [])]
diff --git a/hackage2nix/Stackage.hs b/hackage2nix/Stackage.hs
--- a/hackage2nix/Stackage.hs
+++ b/hackage2nix/Stackage.hs
@@ -4,11 +4,8 @@
 
 module Stackage where
 
-import Control.DeepSeq
 import Control.Exception ( assert )
 import Control.Monad
-import Control.Monad.Par.Combinator
-import Control.Monad.Par.IO
 import Control.Monad.Trans
 import Data.List
 import Data.List.Split
@@ -17,7 +14,6 @@
 import Data.Time.Calendar
 import Data.Yaml
 import Distribution.Compiler
-import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
 import Distribution.Package
 import Distribution.Version
 import GHC.Generics ( Generic )
@@ -47,22 +43,18 @@
             , corePackages :: Map PackageName Version
             , packages :: Map PackageName Spec
             }
-  deriving (Show, Generic)
-
-deriving instance Generic SnapshotType
-instance NFData Spec
-instance NFData Snapshot
-instance NFData SnapshotType
+  deriving (Show)
 
 instance Pretty SnapshotType where
   pPrint STNightly = text "stackage-nightly"
   pPrint (STNightly2 _) = text "stackage-nightly"
   pPrint (STLTS m n) = text "lts-" <> int m <> char '.' <> int n
 
-readLTSHaskell :: FilePath -> ParIO [Snapshot]
+readLTSHaskell :: FilePath -> IO Snapshot
 readLTSHaskell dirPath = do
   filePaths <- liftIO (listFiles dirPath)
-  parMapM (liftIO . readSnapshot) [ dirPath </> p | p <- filePaths, takeExtension p == ".yaml" ]
+  let latest = maximum (Prelude.filter (\p -> takeExtension p == ".yaml") filePaths)
+  readSnapshot (dirPath </> latest)
 
 readStackageNightly :: FilePath -> IO Snapshot
 readStackageNightly dirPath = do
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
@@ -38,7 +38,7 @@
   , _src                        :: DerivationSource
   , _isLibrary                  :: Bool
   , _isExecutable               :: Bool
-  , _extraFunctionArgs          :: Set Identifier
+  , _extraFunctionArgs          :: Set Binding
   , _setupDepends               :: BuildInfo
   , _libraryDepends             :: BuildInfo
   , _executableDepends          :: BuildInfo
@@ -126,7 +126,7 @@
     ]
     where
       inputs :: Set String
-      inputs = Set.unions [ Set.map (view ident) _extraFunctionArgs
+      inputs = Set.unions [ Set.map (view (localName . ident)) _extraFunctionArgs
                           , setOf (dependencies . each . folded . localName . ident) drv
                           , Set.fromList ["fetch" ++ derivKind _src | derivKind _src /= "" && not isHackagePackage]
                           ]
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
@@ -115,7 +115,8 @@
     resolveInNixpkgs :: Identifier -> Binding
     resolveInNixpkgs i
       | i `elem` ["clang","lldb","llvm"] = binding # (i, path # ["self","llvmPackages",i])     -- TODO: evil!
-      | i `elem` ["gtk2","gtk3"]         = binding # (i, path # ["pkgs","gnome2","gtk"])
+      | i == "gtk2"                      = binding # (i, path # ["pkgs","gnome2","gtk"])
+      | i == "gtk3"                      = binding # (i, path # ["pkgs","gnome3","gtk"])
       | Just p <- nixpkgsResolver i, init (view (reference . path) p) `Set.member` goodScopes = p
       | otherwise                        = bindNull i
 
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
@@ -28,7 +28,7 @@
 libNixName "b2"                                 = return "libb2"
 libNixName "bz2"                                = return "bzip2"
 libNixName "c++"                                = []  -- What is that?
-libNixName "cairo"                              = return "cairo"
+libNixName "cairo-gobject"                      = return "cairo"
 libNixName "cairo-pdf"                          = return "cairo"
 libNixName "cairo-ps"                           = return "cairo"
 libNixName "cairo-svg"                          = return "cairo"
@@ -43,8 +43,8 @@
 libNixName "fftw3f"                             = return "fftwFloat"
 libNixName "gconf"                              = return "GConf"
 libNixName "gconf-2.0"                          = return "GConf"
-libNixName "gdk-2.0"                            = return "gdk2"
-libNixName "gdk-3.0"                            = return "gdk3"
+libNixName "gdk-2.0"                            = return "gtk2"
+libNixName "gdk-3.0"                            = return "gtk3"
 libNixName "gdk-pixbuf-2.0"                     = return "gdk_pixbuf"
 libNixName "gdk-x11-2.0"                        = return "gdk_x11"
 libNixName "gio-2.0"                            = return "glib"
@@ -92,6 +92,10 @@
 libNixName "jpeg"                               = return "libjpeg"
 libNixName "lapack"                             = return "liblapack"
 libNixName "ldap"                               = return "openldap"
+libNixName "llvm-3.0"                           = return "llvm"
+libNixName "llvm-3.5"                           = return "llvm"
+libNixName "llvm-3.6"                           = return "llvm"
+libNixName "llvm-3.7"                           = return "llvm"
 libNixName "libavutil"                          = return "ffmpeg"
 libNixName "libglade-2.0"                       = return "libglade"
 libNixName "libgsasl"                           = return "gsasl"
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
@@ -3,6 +3,7 @@
 module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess ) where
 
 import Control.Lens
+import Data.List
 import Data.List.Split
 import Data.Set ( Set )
 import qualified Data.Set as Set
@@ -49,11 +50,16 @@
   , ("eventstore", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64)))
   , ("freenect < 1.2.1", over configureFlags (Set.union (Set.fromList ["--extra-include-dirs=${pkgs.freenect}/include/libfreenect", "--extra-lib-dirs=${pkgs.freenect}/lib"])))
   , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
-  , ("gi-cairo", giPhaseOverrides)      -- https://github.com/haskell-gi/haskell-gi/issues/36
-  , ("gi-gio", giPhaseOverrides)        -- https://github.com/haskell-gi/haskell-gi/issues/36
-  , ("gi-glib", giPhaseOverrides)       -- https://github.com/haskell-gi/haskell-gi/issues/36
-  , ("gi-gobject", giPhaseOverrides)    -- https://github.com/haskell-gi/haskell-gi/issues/36
-  , ("gi-pango", giPhaseOverrides)      -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-cairo", giCairoPhaseOverrides)                     -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-gdk", giGdkPhaseOverrides)                         -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-gdkpixbuf", giGdkPixBufPhaseOverrides)             -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-gio", giPhaseOverrides)                            -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-glib", giPhaseOverrides)                           -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-gobject", giPhaseOverrides)                        -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-gtk", giGtkPhaseOverrides)                         -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-javascriptcore", giJavascriptCorePhaseOverrides)   -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-pango", giPhaseOverrides)                          -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("gi-webkit2", giWebkit2PhaseOverrides)                 -- https://github.com/haskell-gi/haskell-gi/issues/36
   , ("gio", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)
   , ("git", set doCheck False)          -- https://github.com/vincenthz/hit/issues/33
   , ("git-annex", gitAnnexHook)
@@ -64,8 +70,8 @@
   , ("haddock", haddockHook) -- https://github.com/haskell/haddock/issues/511
   , ("hakyll", set (testDepends . tool . contains (pkg "utillinux")) True) -- test suite depends on "rev"
   , ("haskell-src-exts == 1.17.1", set doCheck False) -- test suite fails with ghc 8.0.1
-  , ("hfsevents", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == OSX)))
   , ("HFuse", set phaseOverrides hfusePreConfigure)
+  , ("hfsevents", hfseventsOverrides)
   , ("hlibgit2 >= 0.18.0.14", set (testDepends . tool . contains (pkg "git")) True)
   , ("hmatrix", set phaseOverrides "preConfigure = \"sed -i hmatrix.cabal -e 's@/usr/@/dont/hardcode/paths/@'\";")
   , ("holy-project", set doCheck False)         -- attempts to access the network
@@ -90,6 +96,8 @@
   , ("pandoc", set jailbreak False) -- jailbreak-cabal break the build
   , ("pandoc >= 1.16.0.2", set doCheck False) -- https://github.com/jgm/pandoc/issues/2709 and https://github.com/fpco/stackage/issues/1332
   , ("pandoc-citeproc", set doCheck False) -- https://github.com/jgm/pandoc-citeproc/issues/172
+  , ("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"])))
   , ("rocksdb-haskell", set (metaSection . platforms) (Set.singleton (Platform X86_64 Linux)))
   , ("sdr", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64))) -- https://github.com/adamwalker/sdr/issues/2
@@ -244,140 +252,57 @@
   , "'';"
   ]
 
+exportGirSearchPath :: [String] -> String
+exportGirSearchPath packages =
+  "export HASKELL_GI_GIR_SEARCH_PATH="
+  ++ intercalate ":" [ "${" ++ package ++ "}/share/gir-1.0" | package <- packages]
+
 giPhaseOverrides :: Derivation -> Derivation
 giPhaseOverrides
-  = set phaseOverrides "preConfigure = \"export HASKELL_GI_GIR_SEARCH_PATH=${gobjectIntrospection.dev}/share/gir-1.0\";"
+  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gobjectIntrospection.dev"] ++ "'';")
   . set (libraryDepends . pkgconfig . contains (pkg "gobjectIntrospection")) True
 
-{-
-postProcess' :: Derivation -> Derivation
-postProcess' deriv@(MkDerivation {..})
-  | pname == "alex" && version < Version [3,1] []
-                                = deriv { buildTools = Set.insert "perl" buildTools }
-  | pname == "alex" && version >= Version [3,1] []
-                                = deriv { buildTools = Set.insert "perl" (Set.insert "happy" buildTools) }
-  | pname == "apache-md5"       = deriv { testDepends = Set.delete "crypto" testDepends }
-  | pname == "bits-extras"      = deriv { configureFlags = Set.insert "--ghc-option=-lgcc_s" configureFlags
-                                        , extraLibs = Set.filter (/= "gcc_s") extraLibs
-                                        }
-  | pname == "Cabal"            = deriv { phaseOverrides = "preCheck = \"unset GHC_PACKAGE_PATH; export HOME=$NIX_BUILD_TOP\";" }
-  | pname == "cabal-bounds"     = deriv { buildTools = Set.insert "cabal-install" buildTools }
-  | pname == "editline"         = deriv { extraLibs = Set.insert "libedit" extraLibs }
-  | pname == "ghc-heap-view"    = deriv { phaseOverrides = ghciPostInstall }
-  | pname == "ghc-mod"          = deriv { phaseOverrides = ghcModPostInstall pname version, buildTools = Set.insert "emacs" buildTools }
-  | pname == "ghc-parser"       = deriv { buildTools = Set.insert "cpphs" (Set.insert "happy" buildTools)
-                                        , phaseOverrides = ghcParserPatchPhase }
-  | pname == "ghc-vis"          = deriv { phaseOverrides = ghciPostInstall }
-  | pname == "github-backup"    = deriv { buildTools = Set.insert "git" buildTools }
-  | pname == "gloss-raster"     = deriv { extraLibs = Set.insert "llvm" extraLibs }
-  | pname == "GLUT"             = deriv { extraLibs = Set.fromList ["glut","libSM","libICE","libXmu","libXi","mesa"] `Set.union` extraLibs }
-  | pname == "gtkglext"         = deriv { pkgConfDeps = Set.insert "pangox_compat" pkgConfDeps }
-  | pname == "gtk2hs-buildtools"= deriv { buildDepends = Set.insert "hashtables" buildDepends }
-  | pname == "happy"            = deriv { buildTools = Set.insert "perl" buildTools }
-  | pname == "haskeline"        = deriv { buildDepends = Set.insert "utf8-string" buildDepends }
-  | pname == "haskell-src"      = deriv { buildTools = Set.insert "happy" buildTools }
-  | pname == "haskell-src-meta" = deriv { buildDepends = Set.insert "uniplate" buildDepends }
-  | pname == "hlibgit2"         = deriv { buildTools = Set.insert "git" buildTools }
-  | pname == "HList"            = deriv { buildTools = Set.insert "diffutils" buildTools }
-  | pname == "hmatrix"          = deriv { extraLibs = Set.insert "liblapack" (Set.insert "blas" (Set.filter (/= "lapack") extraLibs)) }
-  | pname == "hmatrix-special"  = deriv { extraLibs = Set.insert "gsl" extraLibs }
-  | pname == "idris"            = deriv { buildTools = Set.insert "happy" buildTools, extraLibs = Set.insert "gmp" (Set.insert "boehmgc" extraLibs) }
-  | pname == "inline-c-cpp"     = deriv { testDepends = Set.delete "stdc++" testDepends }
-  | pname == "language-c-quote" = deriv { buildTools = Set.insert "alex" (Set.insert "happy" buildTools) }
-  | pname == "language-java"    = deriv { buildDepends = Set.insert "syb" buildDepends }
-  | pname == "lhs2tex"          = deriv { extraLibs = Set.insert "texLive" extraLibs, phaseOverrides = lhs2texPostInstall }
-  | pname == "libffi"           = deriv { extraLibs = Set.delete "ffi" extraLibs }
-  | pname == "liquid-fixpoint"  = deriv { buildTools = Set.insert "z3" (Set.insert "ocaml" buildTools), configureFlags = Set.insert "-fbuild-external" configureFlags }
-  | pname == "liquidhaskell"    = deriv { buildTools = Set.insert "z3" buildTools }
-  | pname == "multiarg"         = deriv { buildDepends = Set.insert "utf8-string" buildDepends }
-  | pname == "ncurses"          = deriv { phaseOverrides = ncursesPatchPhase }
-  | pname == "Omega"            = deriv { testDepends = Set.delete "stdc++" testDepends }
-  | pname == "OpenAL"           = deriv { extraLibs = Set.insert "openal" extraLibs }
-  | pname == "OpenGL"           = deriv { extraLibs = Set.insert "mesa" (Set.insert "libX11" extraLibs) }
-  | pname == "pandoc"           = deriv { buildDepends = Set.insert "alex" (Set.insert "happy" buildDepends) }
-  | pname == "persistent"       = deriv { extraLibs = Set.insert "sqlite3" extraLibs }
-  | pname == "purescript"       = deriv { buildTools = Set.insert "nodejs" buildTools }
-  | pname == "repa-algorithms"  = deriv { extraLibs = Set.insert "llvm" extraLibs }
-  | pname == "repa-examples"    = deriv { extraLibs = Set.insert "llvm" extraLibs }
-  | pname == "SDL-image"        = deriv { extraLibs = Set.insert "SDL_image" extraLibs }
-  | pname == "SDL-mixer"        = deriv { extraLibs = Set.insert "SDL_mixer" extraLibs }
-  | pname == "SDL-ttf"          = deriv { extraLibs = Set.insert "SDL_ttf" extraLibs }
-  | pname == "sloane"           = deriv { phaseOverrides = sloanePostInstall }
-  | pname == "structured-haskell-mode" = deriv { buildTools = Set.insert "emacs" buildTools
-                                               , phaseOverrides = structuredHaskellModePostInstall
-                                               }
-  | pname == "target"           = deriv { buildTools = Set.insert "z3" buildTools }
-  | pname == "threadscope"      = deriv { configureFlags = Set.insert "--ghc-options=-rtsopts" configureFlags }
-  | pname == "vacuum"           = deriv { extraLibs = Set.insert "ghc-paths" extraLibs }
-  | pname == "wxcore"           = deriv { extraLibs = Set.fromList ["wxGTK","mesa","libX11"] `Set.union` extraLibs }
-  | pname == "X11-xft"          = deriv { extraLibs = Set.fromList ["pkgconfig","freetype","fontconfig"] `Set.union` extraLibs
-                                        , configureFlags = Set.insert "--extra-include-dirs=${freetype}/include/freetype2" configureFlags
-                                        }
--- Unbreak packages during hackage2nix generation:
-
-  | pname == "hnetcdf"          = deriv { testDepends = Set.delete "netcdf" testDepends }
-  | pname == "SDL2-ttf"         = deriv { buildDepends = Set.delete "SDL2" buildDepends }
-  | pname == "hzk"              = deriv { testDepends = Set.delete "zookeeper_mt" testDepends, buildTools = Set.insert "zookeeper_mt" buildTools }
-  | pname == "z3"               = deriv { phaseOverrides = "preBuild = stdenv.lib.optionalString stdenv.isDarwin \"export DYLD_LIBRARY_PATH=${z3}/lib\";" }
-  | otherwise                   = deriv
-
-ghcModPostInstall :: String -> Version -> String
-ghcModPostInstall pname version = unlines
-  [ "configureFlags = \"--datasubdir=" ++ pname ++ "-" ++ display version ++ "\";"
-  , "postInstall = ''"
-  , "  cd $out/share/" ++ pname ++ "-" ++ display version
-  , "  make"
-  , "  rm Makefile"
-  , "  cd .."
-  , "  ensureDir \"$out/share/emacs\""
-  , "  mv " ++ pname ++ "-" ++ display version ++ " emacs/site-lisp"
-  , "'';"
-  ]
-
-ghciPostInstall :: String
-ghciPostInstall = unlines
-  [ "postInstall = ''"
-  , "  ensureDir \"$out/share/ghci\""
-  , "  ln -s \"$out/share/$pname-$version/ghci\" \"$out/share/ghci/$pname\""
-  , "'';"
-  ]
-
-
-lhs2texPostInstall :: String
-lhs2texPostInstall = unlines
-  [ "postInstall = ''"
-  , "  mkdir -p \"$out/share/doc/$name\""
-  , "  cp doc/Guide2.pdf $out/share/doc/$name"
-  , "  mkdir -p \"$out/nix-support\""
-  , "'';"
-  ]
+giGdkPhaseOverrides :: Derivation -> Derivation
+giGdkPhaseOverrides
+  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gtk3.dev"] ++ "'';")
 
-ncursesPatchPhase :: String
-ncursesPatchPhase = "patchPhase = \"find . -type f -exec sed -i -e 's|ncursesw/||' {} \\\\;\";"
+giGdkPixBufPhaseOverrides :: Derivation -> Derivation
+giGdkPixBufPhaseOverrides
+  = set phaseOverrides (unlines
+    [ "preConfigure = ''"
+    , "  " ++ exportGirSearchPath ["gobjectIntrospection.dev", "gdk_pixbuf.dev"]
+    , "  export GI_TYPELIB_PATH=${gdk_pixbuf.out}/lib/girepository-1.0"
+    , "'';"
+    ])
+  . set (libraryDepends . pkgconfig . contains (pkg "gobjectIntrospection")) True
 
+giGtkPhaseOverrides :: Derivation -> Derivation
+giGtkPhaseOverrides
+  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gtk3.dev"] ++ "'';")
 
-structuredHaskellModePostInstall :: String
-structuredHaskellModePostInstall = unlines
-  [ "postInstall = ''"
-  , "  emacs -L elisp --batch -f batch-byte-compile \"elisp/\"*.el"
-  , "  install -d $out/share/emacs/site-lisp"
-  , "  install \"elisp/\"*.el \"elisp/\"*.elc  $out/share/emacs/site-lisp"
-  , "'';"
-  ]
+giJavascriptCorePhaseOverrides :: Derivation -> Derivation
+giJavascriptCorePhaseOverrides
+  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["webkitgtk"] ++ "'';")
+  . set (libraryDepends . pkgconfig . contains (pkg "webkitgtk")) True
 
-sloanePostInstall :: String
-sloanePostInstall = unlines
-  [ "postInstall = ''"
-  , "  mkdir -p $out/share/man/man1"
-  , "  cp sloane.1 $out/share/man/man1/"
-  , "'';"
-  ]
+giCairoPhaseOverrides :: Derivation -> Derivation
+giCairoPhaseOverrides = over phaseOverrides (++'\n':txt) . giPhaseOverrides
+  where
+    txt = unlines [ "preCompileBuildDriver = ''"
+                  , "  PKG_CONFIG_PATH+=\":${cairo}/lib/pkgconfig\""
+                  , "  setupCompileFlags+=\" $(pkg-config --libs cairo-gobject)\""
+                  , "'';"
+                  ]
 
-ghcParserPatchPhase :: String
-ghcParserPatchPhase = unlines
-  [ "patchPhase = ''"
-  , "  substituteInPlace build-parser.sh --replace \"/bin/bash\" \"$SHELL\""
-  , "'';"
-  ]
+giWebkit2PhaseOverrides :: Derivation -> Derivation
+giWebkit2PhaseOverrides
+  = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["webkitgtk"] ++ "'';")
+  . set (libraryDepends . pkgconfig . contains (pkg "webkitgtk")) True
 
--}
+hfseventsOverrides :: Derivation -> Derivation
+hfseventsOverrides
+  = set isLibrary True
+  . over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == OSX))
+  . set (libraryDepends . tool . contains (bind "pkgs.darwin.apple_sdk.frameworks.CoreServices")) True
+  . set (libraryDepends . system . contains (bind "pkgs.darwin.apple_sdk.frameworks.Cocoa")) True
+  . over (libraryDepends . haskell) (Set.union (Set.fromList (map bind ["self.base", "self.cereal", "self.mtl", "self.text", "self.bytestring"])))
