packages feed

cabal2nix 1.43 → 1.44

raw patch · 10 files changed

+81/−12 lines, 10 filesdep +doctestdep ~base

Dependencies added: doctest

Dependency ranges changed: base

Files

cabal2nix.cabal view
@@ -1,5 +1,5 @@ Name:                   cabal2nix-Version:                1.43+Version:                1.44 Copyright:              Peter Simons, Andres Loeh License:                BSD3 License-File:           LICENSE@@ -10,7 +10,7 @@ Synopsis:               Convert Cabal files into Nix build instructions Cabal-Version:          >= 1.8 Build-Type:             Custom-Tested-With:            GHC >= 6.12.3 && <= 7.6.1+Tested-With:            GHC >= 6.12.3 && <= 7.6.2 Data-files:             README.md Description:   The @cabal2nix@ utility converts Cabal files into Nix build instructions. The@@ -21,6 +21,7 @@   >                  --sha256=HASH            sha256 hash of source tarball   >   -m MAINTAINER  --maintainer=MAINTAINER  maintainer of this package (may be specified multiple times)   >   -p PLATFORM    --platform=PLATFORM      supported build platforms (may be specified multiple times)+  >                  --no-check               don't run regression test suites of this package   >   > Recognized URI schemes:   >@@ -32,8 +33,8 @@   .   The only required argument is the path to the cabal file. For example:   .-  > cabal2nix http://hackage.haskell.org/packages/archive/cabal2nix/1.43/cabal2nix.cabal-  > cabal2nix cabal://cabal2nix-1.43+  > cabal2nix http://hackage.haskell.org/packages/archive/cabal2nix/1.44/cabal2nix.cabal+  > cabal2nix cabal://cabal2nix-1.44   .   If the @--sha256@ option has not been specified, cabal2nix calls   @nix-prefetch-url@ to determine the hash automatically. This causes@@ -81,3 +82,9 @@                         Distribution.NixOS.Derivation.License                         Distribution.NixOS.Derivation.Meta                         Distribution.NixOS.PrettyPrinting++Test-Suite doctest-cabal2nix+  type:                 exitcode-stdio-1.0+  main-is:              doc-test.hs+  hs-source-dirs:       test+  build-depends:        base, doctest
src/Cabal2Nix.hs view
@@ -22,6 +22,7 @@   , optMaintainer :: [String]   , optPlatform :: [String]   , optHaddock :: Bool+  , optDoCheck :: Bool   }   deriving (Show) @@ -33,6 +34,7 @@   , optMaintainer = []   , optPlatform = []   , optHaddock = True+  , optDoCheck = True   }  options :: [OptDescr (Configuration -> Configuration)]@@ -42,6 +44,7 @@   , Option ['m'] ["maintainer"] (ReqArg (\x o -> o { optMaintainer = x : optMaintainer o }) "MAINTAINER")  "maintainer of this package (may be specified multiple times)"   , Option ['p'] ["platform"]   (ReqArg (\x o -> o { optPlatform = x : optPlatform o }) "PLATFORM")        "supported build platforms (may be specified multiple times)"   , Option []    ["no-haddock"] (NoArg (\o -> o { optHaddock = False }))                                   "don't run Haddock when building this package"+  , Option []    ["no-check"]   (NoArg (\o -> o { optDoCheck = False }))                                   "don't run regression test suites of this package"   ]  usage :: String
src/Cabal2Nix/Flags.hs view
@@ -7,6 +7,7 @@ configureCabalFlags (PackageIdentifier (PackageName name) _)  | name == "accelerate-examples"= [disable "opencl"]  | name == "pandoc"             = [enable "blaze_html_0_5"]+ | name == "git-annex"          = [enable "S3", enable "WebDAV", enable "Inotify", enable "Dbus", enable "Assistant", enable "Webapp", enable "Pairing", enable "XMPP", enable "DNS"]  | name == "haskeline"          = [enable "terminfo"]  | name == "reactive-banana-wx" = [disable "buildExamples"]  | name == "xmobar"             = [enable "with_xft", enable "with_iwlib"]
src/Cabal2Nix/Generate.hs view
@@ -21,6 +21,7 @@   , isLibrary      = isJust (Cabal.library tpkg)   , isExecutable   = not (null (Cabal.executables tpkg))   , buildDepends   = map unDep deps+  , testDepends    = map unDep (concatMap Cabal.targetBuildDepends tstDeps)   , buildTools     = map unDep tools   , extraLibs      = libs   , pkgConfDeps    = pcs@@ -28,6 +29,7 @@   , cabalFlags     = configureCabalFlags pkg   , runHaddock     = True   , jailbreak      = False+  , doCheck        = True   , phaseOverrides = ""   , metaSection    = Meta                    { homepage    = Cabal.homepage descr@@ -43,9 +45,10 @@     deps    = Cabal.buildDepends tpkg     libDeps = map Cabal.libBuildInfo (maybeToList (Cabal.library tpkg))     exeDeps = map Cabal.buildInfo (Cabal.executables tpkg)-    tools   = concatMap Cabal.buildTools (libDeps ++ exeDeps)-    libs    = concatMap Cabal.extraLibs (libDeps ++ exeDeps)-    pcs     = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps))+    tstDeps = map Cabal.testBuildInfo (Cabal.testSuites tpkg)+    tools   = concatMap Cabal.buildTools (libDeps ++ exeDeps ++ tstDeps)+    libs    = concatMap Cabal.extraLibs (libDeps ++ exeDeps ++ tstDeps)+    pcs     = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps ++ tstDeps))     Right (tpkg, _) = finalizePackageDescription                         (configureCabalFlags pkg)                         (const True)
src/Cabal2Nix/Name.hs view
@@ -34,6 +34,9 @@ libNixName "gthread-2.0"        = return "glib" libNixName "gtk+-2.0"           = return "gtk" libNixName "gtksourceview-2.0"  = return "gtksourceview"+libNixName "icudata"            = return "icu"+libNixName "icui18n"            = return "icu"+libNixName "icuuc"              = return "icu" libNixName "idn"                = return "libidn" libNixName "iw"                 = return "wirelesstools" libNixName "jpeg"               = return "libjpeg"
src/Cabal2Nix/Normalize.hs view
@@ -12,6 +12,7 @@ normalize :: Derivation -> Derivation normalize deriv@(MkDerivation {..}) = deriv   { buildDepends = normalizeNixNames (filter (`notElem` (pname : corePackages)) buildDepends)+  , testDepends  = normalizeNixNames (filter (`notElem` (pname : corePackages)) testDepends)   , buildTools   = normalizeNixBuildTools (filter (`notElem` coreBuildTools) buildTools)   , extraLibs    = normalizeNixLibs extraLibs   , pkgConfDeps  = normalizeNixLibs pkgConfDeps
src/Cabal2Nix/PostProcess.hs view
@@ -16,6 +16,7 @@   | pname == "editline"         = deriv { extraLibs = "libedit":extraLibs }   | pname == "epic"             = deriv { extraLibs = "gmp":"boehmgc":extraLibs, buildTools = "happy":buildTools }   | pname == "ghc-mod"          = deriv { phaseOverrides = ghcModPostInstall, buildTools = "emacs":buildTools }+  | pname == "git-annex"        = deriv { buildTools = "git":"rsync":"gnupg1":"curl":"lsof":"openssh":"bup":buildTools }   | pname == "glade"            = deriv { extraLibs = "pkgconfig":"libc":extraLibs, pkgConfDeps = "gtkC":delete "gtk" pkgConfDeps }   | pname == "glib"             = deriv { extraLibs = "pkgconfig":"libc":extraLibs }   | pname == "GLUT"             = deriv { extraLibs = "glut":"libSM":"libICE":"libXmu":"libXi":"mesa":extraLibs }@@ -53,6 +54,7 @@   | pname == "X11-xft"          = deriv { extraLibs = "pkgconfig":"freetype":"fontconfig":extraLibs                                         , configureFlags = "--extra-include-dirs=${freetype}/include/freetype2":configureFlags                                         }+  | pname == "xmonad"           = deriv { phaseOverrides = xmonadPostInstall }   | otherwise                   = deriv  cudaConfigurePhase :: String@@ -126,3 +128,11 @@   { phaseOverrides = "prePatch = \"sed -i -e 's|regex-pcre-builtin|regex-pcre|' highlighting-kate.cabal\";"   , buildDepends = "regex-pcre" : filter (/="regex-pcre-builtin") buildDepends   }++xmonadPostInstall :: String+xmonadPostInstall = unlines+  [ "postInstall = ''"+  , "  mkdir -p $out/share/man/man1"+  , "  mv $out/share/xmonad-*/man/*.1 $out/share/man/man1/"+  , "'';"+  ]
src/Distribution/NixOS/Derivation/Cabal.hs view
@@ -47,6 +47,7 @@   , isLibrary           :: Bool   , isExecutable        :: Bool   , buildDepends        :: [String]+  , testDepends         :: [String]   , buildTools          :: [String]   , extraLibs           :: [String]   , pkgConfDeps         :: [String]@@ -54,6 +55,7 @@   , cabalFlags          :: FlagAssignment   , runHaddock          :: Bool   , jailbreak           :: Bool+  , doCheck             :: Bool   , phaseOverrides      :: String   , metaSection         :: Meta   }@@ -77,12 +79,14 @@     , boolattr "isLibrary" (not (isLibrary deriv) || isExecutable deriv) (isLibrary deriv)     , boolattr "isExecutable" (not (isLibrary deriv) || isExecutable deriv) (isExecutable deriv)     , listattr "buildDepends" (buildDepends deriv)+    , listattr "testDepends" (testDepends deriv)     , listattr "buildTools" (buildTools deriv)     , listattr "extraLibraries" (extraLibs deriv)     , listattr "pkgconfigDepends" (pkgConfDeps deriv)     , onlyIf renderedFlags $ attr "configureFlags" $ doubleQuotes (sep renderedFlags)     , boolattr "noHaddock" (not (runHaddock deriv)) (not (runHaddock deriv))     , boolattr "jailbreak" (jailbreak deriv) (jailbreak deriv)+    , boolattr "doCheck" (not (doCheck deriv)) (doCheck deriv)     , onlyIf (phaseOverrides deriv) $ vcat ((map text . lines) (phaseOverrides deriv))     , disp (metaSection deriv)     ]@@ -91,7 +95,7 @@   ]   where     inputs = nub $ sortBy (compare `on` map toLower) $ filter (/="cabal") $ filter (not . isPrefixOf "self.") $-              buildDepends deriv ++ buildTools deriv ++ extraLibs deriv ++ pkgConfDeps deriv+              buildDepends deriv ++ testDepends deriv ++ buildTools deriv ++ extraLibs deriv ++ pkgConfDeps deriv     renderedFlags =  [ text "-f" <> (if enable then empty else char '-') <> text f | (FlagName f, enable) <- cabalFlags deriv ]                   ++ map text (configureFlags deriv) @@ -110,6 +114,7 @@   , maint     <- buf `regsubmatch` "maintainers *= *\\[([^\"]+)]"   , noHaddock <- buf `regsubmatch` "noHaddock *= *(true|false) *;"   , jailBreak <- buf `regsubmatch` "jailbreak *= *(true|false) *;"+  , docheck   <- buf `regsubmatch` "doCheck *= *(true|false) *;"               = Just MkDerivation                   { pname          = name                   , version        = vers@@ -117,6 +122,7 @@                   , isLibrary      = False                   , isExecutable   = False                   , buildDepends   = []+                  , testDepends    = []                   , buildTools     = []                   , extraLibs      = []                   , pkgConfDeps    = []@@ -124,6 +130,7 @@                   , cabalFlags     = []                   , runHaddock     = noHaddock /= ["true"]                   , jailbreak      = jailBreak == ["true"]+                  , doCheck        = docheck == ["true"] || docheck == []                   , phaseOverrides = ""                   , metaSection  = Meta                                    { homepage    = ""
src/Hackage4Nix.hs view
@@ -114,7 +114,7 @@         when regenerate $ do           msgDebug ("re-generate " ++ path)           pkg <- getCabalPackage (pname deriv) (version deriv)-          let deriv'  = (cabal2nix pkg) { sha256 = sha256 deriv, runHaddock = runHaddock deriv, jailbreak = jailbreak deriv }+          let deriv'  = (cabal2nix pkg) { sha256 = sha256 deriv, runHaddock = runHaddock deriv, jailbreak = jailbreak deriv, doCheck = doCheck deriv }               meta    = metaSection deriv'               plats'  = if null plats then platforms meta else plats               deriv'' = deriv' { metaSection = meta@@ -144,7 +144,7 @@ genCabal2NixCmdline (Pkg deriv path _) = unwords $ ["cabal2nix"] ++ opts ++ ['>':path']   where     meta = metaSection deriv-    opts = [cabal] ++ maints' ++ plats' ++ if runHaddock deriv then [] else ["--no-haddock"]+    opts = [cabal] ++ maints' ++ plats' ++ (if runHaddock deriv then [] else ["--no-haddock"]) ++ (if doCheck deriv then [] else ["--no-check"])     cabal = "cabal://" ++ display (packageId deriv)     maints' = [ "--maintainer=" ++ normalizeMaintainer m | m <- maintainers meta ]     plats'@@ -166,8 +166,8 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do   let options :: [OptDescr CliOption]       options =-        [ Option ['h'] ["help"]     (NoArg PrintHelp)                 "show this help text"-        , Option ['v'] ["verbose"]  (NoArg Verbose)                   "enable noisy debug output"+        [ Option "h" ["help"]     (NoArg PrintHelp)                 "show this help text"+        , Option "v" ["verbose"]  (NoArg Verbose)                   "enable noisy debug output"         ]        usage :: String@@ -204,6 +204,7 @@ badPackagePaths :: [FilePath] badPackagePaths = [ "haskell-platform/2011.2.0.1.nix", "haskell-platform/2011.4.0.0.nix"                   , "haskell-platform/2012.2.0.0.nix", "haskell-platform/2012.4.0.0.nix"+                  , "top-level/all-packages.nix"                   ]  -- Packages that we cannot regenerate automatically yet. This list
+ test/doc-test.hs view
@@ -0,0 +1,33 @@+{-+   Module      :  Main+   Copyright   :  (c) 2013 Peter Simons+   License     :  BSD3++   Maintainer  :  simons@cryp.to+   Stability   :  provisional+   Portability :  portable++   Cabal2nix doctest suite.+-}++module Main ( main ) where++import Test.DocTest++main :: IO ()+main = do+  let libs = [ "src/Cabal2Nix/License.hs"+             , "src/Cabal2Nix/CorePackages.hs"+             , "src/Cabal2Nix/Flags.hs"+             , "src/Cabal2Nix/Generate.hs"+             , "src/Cabal2Nix/Hackage.hs"+             , "src/Cabal2Nix/Normalize.hs"+             , "src/Cabal2Nix/Name.hs"+             , "src/Cabal2Nix/PostProcess.hs"+             , "src/Distribution/NixOS/Derivation/License.hs"+             , "src/Distribution/NixOS/Derivation/Cabal.hs"+             , "src/Distribution/NixOS/Derivation/Meta.hs"+             , "src/Distribution/NixOS/PrettyPrinting.hs"+             ]+  doctest $ "src/Cabal2Nix.hs" : libs+  doctest $ "src/Hackage4Nix.hs" : libs