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
commit52e60f7ad60f2a75a961e78d8f3d60852dca6140 authorPeter Simons <simons@cryp.to> dateFri 26 Aug 2011, 12:15 (15 years ago) parenta3f42bd
3 files changed+23−20
src/Cabal2Nix/Flags.hs+7−5 src/Cabal2Nix/Generate.hs+15−14 src/Hackage4Nix.hs+1−1
src/Cabal2Nix/Flags.hs+7−5
@@ -1,12 +1,14 @@
1−module Cabal2Nix.Flags ( configureFlags ) where
1+module Cabal2Nix.Flags ( pkgConfigureFlags ) where
22
33import Distribution.Package
44import Distribution.PackageDescription
55
6−configureFlags :: PackageIdentifier -> FlagAssignment
7−configureFlags (PackageIdentifier (PackageName name) _)
8− | name == "pandoc" = [enable "highlighting", enable "threaded"]
9− | otherwise = []
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+ | otherwise = ([],[])
1012
1113enable :: String -> (FlagName,Bool)
1214enable name = (FlagName name, True)
src/Cabal2Nix/Generate.hs+15−14
@@ -15,17 +15,18 @@ import Distribution.NixOS.Derivation.Cabal
1515
1616cabal2nix :: Cabal.GenericPackageDescription -> Derivation
1717cabal2nix cabal = normalize $ postProcess $ MkDerivation
18− { pname = let Cabal.PackageName x = Cabal.pkgName pkg in x
19− , version = Cabal.pkgVersion pkg
20− , sha256 = "cabal2nix left the she256 field undefined"
21− , isLibrary = isJust (Cabal.library tpkg)
22− , isExecutable = not (null (Cabal.executables tpkg))
23− , buildDepends = map unDep deps
24− , buildTools = map unDep tools
25− , extraLibs = libs
26− , pkgConfDeps = pcs
27− , runHaddock = True
28− , metaSection = Meta
18+ { pname = let Cabal.PackageName x = Cabal.pkgName pkg in x
19+ , version = Cabal.pkgVersion pkg
20+ , sha256 = "cabal2nix left the she256 field undefined"
21+ , isLibrary = isJust (Cabal.library tpkg)
22+ , isExecutable = not (null (Cabal.executables tpkg))
23+ , buildDepends = map unDep deps
24+ , buildTools = map unDep tools
25+ , extraLibs = libs
26+ , pkgConfDeps = pcs
27+ , configureFlags = pkgConfigureFlags pkg
28+ , runHaddock = True
29+ , metaSection = Meta
2930 { homepage = Cabal.homepage descr
3031 , description = Cabal.synopsis descr
3132 , license = fromCabalLicense (Cabal.license descr)
@@ -34,8 +35,8 @@ cabal2nix cabal = normalize $ postProcess $ MkDerivation
3435 }
3536 }
3637 where
37− descr = Cabal.packageDescription cabal
38− pkg = Cabal.package descr
38+ descr = Cabal.packageDescription cabal
39+ pkg = Cabal.package descr
3940 deps = Cabal.buildDepends tpkg
4041 libDeps = map Cabal.libBuildInfo (maybeToList (Cabal.library tpkg))
4142 exeDeps = map Cabal.buildInfo (Cabal.executables tpkg)
@@ -43,7 +44,7 @@ cabal2nix cabal = normalize $ postProcess $ MkDerivation
4344 libs = concatMap Cabal.extraLibs (libDeps ++ exeDeps)
4445 pcs = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps))
4546 Right (tpkg, _) = finalizePackageDescription
46− (configureFlags pkg)
47+ (fst (pkgConfigureFlags pkg))
4748 (const True)
4849 (Platform I386 Linux) -- shouldn't be hardcoded
4950 (CompilerId GHC (Version [7,0,4] [])) -- dito
src/Hackage4Nix.hs+1−1
@@ -73,7 +73,7 @@ discoverNixFiles yield dirOrFile = do
7373
7474regenerateDerivation :: Derivation -> String -> Bool
7575regenerateDerivation 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")
7777
7878parseNixFile :: FilePath -> String -> Hackage4Nix (Maybe Pkg)
7979parseNixFile path buf