git.iko.soy/typeable/cabal2nix
on master help sign in
Cabal2Nix: generalized configureFlag support so that it supports FlagAssignment as well as other extra flags
52e60f7Peter Simons
src/Cabal2Nix/Flags.hs+7−5
@@ -1,12 +1,14 @@
1−module Cabal2Nix.Flags ( configureFlags ) where
1+module Cabal2Nix.Flags ( pkgConfigureFlags ) where
2
2
3import Distribution.Package
3import Distribution.Package
4import Distribution.PackageDescription
4import Distribution.PackageDescription
5
5
6−configureFlags :: PackageIdentifier -> FlagAssignment
6+pkgConfigureFlags :: PackageIdentifier -> (FlagAssignment,[String])
7−configureFlags (PackageIdentifier (PackageName name) _)
7+pkgConfigureFlags (PackageIdentifier (PackageName name) _)
8− | name == "pandoc" = [enable "highlighting", enable "threaded"]
8+ | name == "pandoc" = ([enable "highlighting", enable "threaded"],[])
9+ | name == "threadscope" = ([], ["--ghc-options=-rtsopts"])
10+ | name == "X11-xft" = ([], ["--extra-include-dirs=${freetype}/include/freetype2"])
9− | otherwise = []
11+ | otherwise = ([],[])
10
12
11enable :: String -> (FlagName,Bool)
13enable :: String -> (FlagName,Bool)
12enable name = (FlagName name, True)
14enable name = (FlagName name, True)
src/Cabal2Nix/Generate.hs+15−14
@@ -15,17 +15,18 @@ import Distribution.NixOS.Derivation.Cabal
15
15
16cabal2nix :: Cabal.GenericPackageDescription -> Derivation
16cabal2nix :: Cabal.GenericPackageDescription -> Derivation
17cabal2nix cabal = normalize $ postProcess $ MkDerivation
17cabal2nix cabal = normalize $ postProcess $ MkDerivation
18− { pname = let Cabal.PackageName x = Cabal.pkgName pkg in x
18+ { pname = let Cabal.PackageName x = Cabal.pkgName pkg in x
19− , version = Cabal.pkgVersion pkg
19+ , version = Cabal.pkgVersion pkg
20− , sha256 = "cabal2nix left the she256 field undefined"
20+ , sha256 = "cabal2nix left the she256 field undefined"
21− , isLibrary = isJust (Cabal.library tpkg)
21+ , isLibrary = isJust (Cabal.library tpkg)
22− , isExecutable = not (null (Cabal.executables tpkg))
22+ , isExecutable = not (null (Cabal.executables tpkg))
23− , buildDepends = map unDep deps
23+ , buildDepends = map unDep deps
24− , buildTools = map unDep tools
24+ , buildTools = map unDep tools
25− , extraLibs = libs
25+ , extraLibs = libs
26− , pkgConfDeps = pcs
26+ , pkgConfDeps = pcs
27+ , configureFlags = pkgConfigureFlags pkg
27− , runHaddock = True
28+ , runHaddock = True
28− , metaSection = Meta
29+ , metaSection = Meta
29 { homepage = Cabal.homepage descr
30 { homepage = Cabal.homepage descr
30 , description = Cabal.synopsis descr
31 , description = Cabal.synopsis descr
31 , license = fromCabalLicense (Cabal.license descr)
32 , license = fromCabalLicense (Cabal.license descr)
@@ -34,8 +35,8 @@ cabal2nix cabal = normalize $ postProcess $ MkDerivation
34 }
35 }
35 }
36 }
36 where
37 where
37− descr = Cabal.packageDescription cabal
38+ descr = Cabal.packageDescription cabal
38− pkg = Cabal.package descr
39+ pkg = Cabal.package descr
39 deps = Cabal.buildDepends tpkg
40 deps = Cabal.buildDepends tpkg
40 libDeps = map Cabal.libBuildInfo (maybeToList (Cabal.library tpkg))
41 libDeps = map Cabal.libBuildInfo (maybeToList (Cabal.library tpkg))
41 exeDeps = map Cabal.buildInfo (Cabal.executables tpkg)
42 exeDeps = map Cabal.buildInfo (Cabal.executables tpkg)
@@ -43,7 +44,7 @@ cabal2nix cabal = normalize $ postProcess $ MkDerivation
43 libs = concatMap Cabal.extraLibs (libDeps ++ exeDeps)
44 libs = concatMap Cabal.extraLibs (libDeps ++ exeDeps)
44 pcs = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps))
45 pcs = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps))
45 Right (tpkg, _) = finalizePackageDescription
46 Right (tpkg, _) = finalizePackageDescription
46− (configureFlags pkg)
47+ (fst (pkgConfigureFlags pkg))
47 (const True)
48 (const True)
48 (Platform I386 Linux) -- shouldn't be hardcoded
49 (Platform I386 Linux) -- shouldn't be hardcoded
49 (CompilerId GHC (Version [7,0,4] [])) -- dito
50 (CompilerId GHC (Version [7,0,4] [])) -- dito
src/Hackage4Nix.hs+1−1
@@ -73,7 +73,7 @@ discoverNixFiles yield dirOrFile = do
73
73
74regenerateDerivation :: Derivation -> String -> Bool
74regenerateDerivation :: Derivation -> String -> Bool
75regenerateDerivation deriv buf = not (pname deriv `elem` patchedPackages) &&
75regenerateDerivation deriv buf = not (pname deriv `elem` patchedPackages) &&
76− not (buf =~ "(pre|post)Configure|configureFlags|(pre|post)Install|patchPhase")
76+ not (buf =~ "(pre|post)Configure|(pre|post)Install|patchPhase")
77
77
78parseNixFile :: FilePath -> String -> Hackage4Nix (Maybe Pkg)
78parseNixFile :: FilePath -> String -> Hackage4Nix (Maybe Pkg)
79parseNixFile path buf
79parseNixFile path buf