git.iko.soy/typeable/cabal2nix
on master help sign in
Don't mix cabal flags and general-purpose configure flags in the same type.
commite90b4045a81a85b4846c3c28ee7ddc276d76ffbd authorPeter Simons <simons@cryp.to> dateMon 19 Sep 2011, 21:30 (15 years ago) parent6a16d65
4 files changed+17−15
cabal2nix.cabal+3−3 src/Cabal2Nix/Flags.hs+7−9 src/Cabal2Nix/Generate.hs+3−2 src/Cabal2Nix/PostProcess.hs+4−1
cabal2nix.cabal+3−3
@@ -1,5 +1,5 @@
11Name: cabal2nix
2−Version: 1.17
2+Version: 1.18
33Copyright: Peter Simons, Andres Loeh
44License: BSD3
55License-File: LICENSE
@@ -46,7 +46,7 @@ Executable cabal2nix
4646 main-is: Cabal2Nix.hs
4747 hs-source-dirs: src
4848 Build-Depends: base >= 3 && < 5, regex-posix, pretty, Cabal >= 1.8,
49− filepath, directory, process, HTTP, nixos-types
49+ filepath, directory, process, HTTP, nixos-types >= 1.2
5050 Extensions: PatternGuards, RecordWildCards, CPP
5151 Ghc-Options: -Wall
5252 other-modules: Cabal2Nix.CorePackages
@@ -62,7 +62,7 @@ Executable hackage4nix
6262 main-is: Hackage4Nix.hs
6363 hs-source-dirs: src
6464 Build-Depends: base >= 3 && < 5, regex-posix, pretty, Cabal >= 1.8,
65− mtl, containers, directory, filepath, nixos-types >= 1.1,
65+ mtl, containers, directory, filepath, nixos-types >= 1.2,
6666 hackage-db
6767 Extensions: PatternGuards, RecordWildCards, CPP
6868 Ghc-Options: -Wall
src/Cabal2Nix/Flags.hs+7−9
@@ -1,16 +1,14 @@
1−module Cabal2Nix.Flags ( pkgConfigureFlags ) where
1+module Cabal2Nix.Flags ( configureCabalFlags ) where
22
33import Distribution.Package
44import Distribution.PackageDescription
55
6−pkgConfigureFlags :: PackageIdentifier -> (FlagAssignment,[String])
7−pkgConfigureFlags (PackageIdentifier (PackageName name) _)
8− | name == "pandoc" = ([enable "highlighting", enable "threaded"],[])
9− | name == "threadscope" = ([], ["--ghc-options=-rtsopts"])
10− | name == "X11-xft" = ([], ["--extra-include-dirs=${freetype}/include/freetype2"])
11− | name == "xmonad-extras" = ([disable "with_hlist", disable "with_mpd"], [])
12− | name == "xmobar" = ([enable "with_xft"], [])
13− | otherwise = ([],[])
6+configureCabalFlags :: PackageIdentifier -> FlagAssignment
7+configureCabalFlags (PackageIdentifier (PackageName name) _)
8+ | name == "pandoc" = [enable "highlighting", enable "threaded"]
9+ | name == "xmonad-extras" = [disable "with_hlist", disable "with_mpd"]
10+ | name == "xmobar" = [enable "with_xft"]
11+ | otherwise = []
1412
1513enable :: String -> (FlagName,Bool)
1614enable name = (FlagName name, True)
src/Cabal2Nix/Generate.hs+3−2
@@ -24,7 +24,8 @@ cabal2nix cabal = normalize $ postProcess $ MkDerivation
2424 , buildTools = map unDep tools
2525 , extraLibs = libs
2626 , pkgConfDeps = pcs
27− , configureFlags = pkgConfigureFlags pkg
27+ , configureFlags = []
28+ , cabalFlags = configureCabalFlags pkg
2829 , runHaddock = True
2930 , metaSection = Meta
3031 { homepage = Cabal.homepage descr
@@ -44,7 +45,7 @@ cabal2nix cabal = normalize $ postProcess $ MkDerivation
4445 libs = concatMap Cabal.extraLibs (libDeps ++ exeDeps)
4546 pcs = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps))
4647 Right (tpkg, _) = finalizePackageDescription
47− (fst (pkgConfigureFlags pkg))
48+ (configureCabalFlags pkg)
4849 (const True)
4950 (Platform I386 Linux) -- shouldn't be hardcoded
5051 (CompilerId GHC (Version [7,0,4] [])) -- dito
src/Cabal2Nix/PostProcess.hs+4−1
@@ -30,8 +30,11 @@ postProcess deriv@(MkDerivation {..})
3030 | pname == "SDL-ttf" = deriv { extraLibs = "SDL_ttf":extraLibs }
3131 | pname == "svgcairo" = deriv { extraLibs = "libc":extraLibs }
3232 | pname == "terminfo" = deriv { extraLibs = "ncurses":extraLibs }
33+ | pname == "threadscope" = deriv { configureFlags = "--ghc-options=-rtsopts":configureFlags }
3334 | pname == "vacuum" = deriv { extraLibs = "ghcPaths":extraLibs }
3435 | pname == "wxcore" = deriv { extraLibs = "wxGTK":"mesa":"libX11":extraLibs }
3536 | pname == "X11" = deriv { extraLibs = "libXinerama":"libXext":extraLibs }
36− | pname == "X11-xft" = deriv { extraLibs = "pkgconfig":"freetype":"fontconfig":extraLibs }
37+ | pname == "X11-xft" = deriv { extraLibs = "pkgconfig":"freetype":"fontconfig":extraLibs
38+ , configureFlags = "--extra-include-dirs=${freetype}/include/freetype2":configureFlags
39+ }
3740 | otherwise = deriv