diff --git a/cabal2nix.cabal b/cabal2nix.cabal
--- a/cabal2nix.cabal
+++ b/cabal2nix.cabal
@@ -1,5 +1,5 @@
 Name:                   cabal2nix
-Version:                1.17
+Version:                1.18
 Copyright:              Peter Simons, Andres Loeh
 License:                BSD3
 License-File:           LICENSE
@@ -46,7 +46,7 @@
   main-is:              Cabal2Nix.hs
   hs-source-dirs:       src
   Build-Depends:        base >= 3 && < 5, regex-posix, pretty, Cabal >= 1.8,
-                        filepath, directory, process, HTTP, nixos-types
+                        filepath, directory, process, HTTP, nixos-types >= 1.2
   Extensions:           PatternGuards, RecordWildCards, CPP
   Ghc-Options:          -Wall
   other-modules:        Cabal2Nix.CorePackages
@@ -62,7 +62,7 @@
   main-is:              Hackage4Nix.hs
   hs-source-dirs:       src
   Build-Depends:        base >= 3 && < 5, regex-posix, pretty, Cabal >= 1.8,
-                        mtl, containers, directory, filepath, nixos-types >= 1.1,
+                        mtl, containers, directory, filepath, nixos-types >= 1.2,
                         hackage-db
   Extensions:           PatternGuards, RecordWildCards, CPP
   Ghc-Options:          -Wall
diff --git a/src/Cabal2Nix/Flags.hs b/src/Cabal2Nix/Flags.hs
--- a/src/Cabal2Nix/Flags.hs
+++ b/src/Cabal2Nix/Flags.hs
@@ -1,16 +1,15 @@
-module Cabal2Nix.Flags ( pkgConfigureFlags ) where
+module Cabal2Nix.Flags ( configureCabalFlags ) where
 
 import Distribution.Package
 import Distribution.PackageDescription
 
-pkgConfigureFlags :: PackageIdentifier -> (FlagAssignment,[String])
-pkgConfigureFlags (PackageIdentifier (PackageName name) _)
- | name == "pandoc"             = ([enable "highlighting", enable "threaded"],[])
- | name == "threadscope"        = ([], ["--ghc-options=-rtsopts"])
- | name == "X11-xft"            = ([], ["--extra-include-dirs=${freetype}/include/freetype2"])
- | name == "xmonad-extras"      = ([disable "with_hlist", disable "with_mpd"], [])
- | name == "xmobar"             = ([enable "with_xft"], [])
- | otherwise                    = ([],[])
+configureCabalFlags :: PackageIdentifier -> FlagAssignment
+configureCabalFlags (PackageIdentifier (PackageName name) _)
+ | name == "hmatrix"            = [enable "vector"]
+ | name == "pandoc"             = [enable "highlighting", enable "threaded"]
+ | name == "xmonad-extras"      = [disable "with_hlist", disable "with_mpd"]
+ | name == "xmobar"             = [enable "with_xft"]
+ | otherwise                    = []
 
 enable :: String -> (FlagName,Bool)
 enable name = (FlagName name, True)
diff --git a/src/Cabal2Nix/Generate.hs b/src/Cabal2Nix/Generate.hs
--- a/src/Cabal2Nix/Generate.hs
+++ b/src/Cabal2Nix/Generate.hs
@@ -24,7 +24,8 @@
   , buildTools     = map unDep tools
   , extraLibs      = libs
   , pkgConfDeps    = pcs
-  , configureFlags = pkgConfigureFlags pkg
+  , configureFlags = []
+  , cabalFlags     = configureCabalFlags pkg
   , runHaddock     = True
   , metaSection    = Meta
                    { homepage    = Cabal.homepage descr
@@ -44,7 +45,7 @@
     libs    = concatMap Cabal.extraLibs (libDeps ++ exeDeps)
     pcs     = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps))
     Right (tpkg, _) = finalizePackageDescription
-                        (fst (pkgConfigureFlags pkg))
+                        (configureCabalFlags pkg)
                         (const True)
                         (Platform I386 Linux)                   -- shouldn't be hardcoded
                         (CompilerId GHC (Version [7,0,4] []))   -- dito
diff --git a/src/Cabal2Nix/PostProcess.hs b/src/Cabal2Nix/PostProcess.hs
--- a/src/Cabal2Nix/PostProcess.hs
+++ b/src/Cabal2Nix/PostProcess.hs
@@ -16,6 +16,7 @@
   | pname == "GLUT"             = deriv { extraLibs = "glut":"libSM":"libICE":"libXmu":"libXi":"mesa":extraLibs }
   | pname == "gtk"              = deriv { extraLibs = "pkgconfig":"libc":extraLibs, buildDepends = delete "gio" buildDepends }
   | pname == "gtksourceview2"   = deriv { extraLibs = "pkgconfig":"libc":extraLibs }
+  | pname == "haddock"          = deriv { buildTools = "alex":"happy":buildTools }
   | pname == "happy"            = deriv { buildTools = "perl":buildTools }
   | pname == "haskell-src"      = deriv { buildTools = "happy":buildTools }
   | pname == "hmatrix"          = deriv { extraLibs = "gsl":"liblapack":"blas":extraLibs }
@@ -30,8 +31,11 @@
   | pname == "SDL-ttf"          = deriv { extraLibs = "SDL_ttf":extraLibs }
   | pname == "svgcairo"         = deriv { extraLibs = "libc":extraLibs }
   | pname == "terminfo"         = deriv { extraLibs = "ncurses":extraLibs }
+  | pname == "threadscope"      = deriv { configureFlags = "--ghc-options=-rtsopts":configureFlags }
   | pname == "vacuum"           = deriv { extraLibs = "ghcPaths":extraLibs }
   | pname == "wxcore"           = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs }
   | pname == "X11"              = deriv { extraLibs = "libXinerama":"libXext":extraLibs }
-  | pname == "X11-xft"          = deriv { extraLibs = "pkgconfig":"freetype":"fontconfig":extraLibs }
+  | pname == "X11-xft"          = deriv { extraLibs = "pkgconfig":"freetype":"fontconfig":extraLibs
+                                        , configureFlags = "--extra-include-dirs=${freetype}/include/freetype2":configureFlags
+                                        }
   | otherwise                   = deriv
