@@ -19,6 +19,8 @@ import Distribution.PackageDescription.Parse ( parsePackageDescription, ParseRes
19import Distribution.PackageDescription ( GenericPackageDescription() )
19import Distribution.PackageDescription ( GenericPackageDescription() )
20import System.Console.GetOpt ( OptDescr(..), ArgDescr(..), ArgOrder(..), usageInfo, getOpt )
20import System.Console.GetOpt ( OptDescr(..), ArgDescr(..), ArgOrder(..), usageInfo, getOpt )
21import Cabal2Nix.Package ( cabal2nix, showNixPkg, PkgName, PkgSHA256, PkgPlatforms, PkgMaintainers )
21import Cabal2Nix.Package ( cabal2nix, showNixPkg, PkgName, PkgSHA256, PkgPlatforms, PkgMaintainers )
22+import qualified Cabal2Nix.Package ( Pkg(..) )
23+import Hackage4Nix.Nix
23type ByteString = BS.ByteString
25type ByteString = BS.ByteString
@@ -101,33 +103,20 @@ normalizeMaintainer x
101 | otherwise = x
103 | otherwise = x
103parseNixFile :: FilePath -> ByteString -> Hackage4Nix (Maybe Pkg)
105parseNixFile :: FilePath -> ByteString -> Hackage4Nix (Maybe Pkg)
104−parseNixFile path buf
106+parseNixFile path buf'
107+ | not (buf' `regmatch` "cabal.mkDerivation")
108+ = msgDebug ("ignore non-cabal package " ++ path) >> return Nothing
105− | True <- (pack path) `regmatch` (concat (intersperse "|" badPackages))
109+ | (pack path) `regmatch` (concat (intersperse "|" badPackages))
106− = msgDebug ("ignore known bad package " ++ path) >> return Nothing
110+ = msgDebug ("ignore known bad package " ++ path) >> return Nothing
107− | True <- buf `regmatch` "src = (fetchgit|sourceFromHead)"
111+ | otherwise = do
108− = msgDebug ("ignore non-hackage package " ++ path) >> return Nothing
112+ let buf = BS.unpack buf'
109− | True <- buf `regmatch` "(patchPhase|configureFlags) ="
113+ tree <- parseNixExpr buf
110− = msgDebug ("ignore patched package " ++ path) >> return Nothing
114+ let pkg' = nixExpr2CabalExpr tree
111− | True <- buf `regmatch` "noHaddock"
115+ Cabal2Nix.Package.Pkg pkgname pkgver sha256 url desc lic isLib isExe deps tools libs pcs plats maints = pkg'
112− = msgDebug ("ignore non-haddock package " ++ path) >> return Nothing
116+ pkg = Pkg pkgname pkgver sha256 plats (map normalizeMaintainer maints) path
113− | True <- buf =~ pack "cabal.mkDerivation"
117+ msgDebug ("pkg = " ++ show pkg')
114− , [name] <- buf `regsubmatch` "name *= *\"([^\"]+)\""
118+ msgDebug ("pkg = " ++ show pkg)
115− , [vers] <- buf `regsubmatch` "version *= *\"([^\"]+)\""
116− , [sha] <- buf `regsubmatch` "sha256 *= *\"([^\"]+)\""
117− , plats <- buf `regsubmatch` "platforms *= *([^;]+);"
118− , maint <- buf `regsubmatch` "maintainers *= *\\[([^\"]+)]"
119− = let plats' = concatMap BS.words (map (BS.map (\c -> if c == '+' then ' ' else c)) plats)
120− maint' = concatMap BS.words maint
122− return $ Just $ Pkg (unpack name)
119+ return (Just pkg)
126− (map (normalizeMaintainer . unpack) maint')
128− | True <- buf `regmatch` "cabal.mkDerivation"
129− = msgInfo ("failed to parse file " ++ path) >> return Nothing
130− | otherwise = return Nothing
132readVersion :: String -> Version
121readVersion :: String -> Version
133readVersion str =
122readVersion str =
@@ -252,6 +241,11 @@ badPackages :: [String]
252badPackages = [ "/"++p++"/" | p <- names ]
241badPackages = [ "/"++p++"/" | p <- names ]
253 where names =
242 where names =
247+ , "WebServer-Extras"
255 , "cairo"
249 , "cairo"
256 , "citeproc"
250 , "citeproc"
257 , "citeproc-hs"
251 , "citeproc-hs"