packages feed

cabal2nix 2.7 → 2.7.1

raw patch · 6 files changed

+123/−73 lines, 6 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Distribution.Nixpkgs.Haskell.BuildInfo: instance Control.Lens.Each.Each Distribution.Nixpkgs.Haskell.BuildInfo.BuildInfo Distribution.Nixpkgs.Haskell.BuildInfo.BuildInfo (Data.Set.Base.Set Language.Nix.Binding.Binding) (Data.Set.Base.Set Language.Nix.Binding.Binding)
+ Cabal2nix: cabal2nixWithDB :: HackageDB -> [String] -> IO (Either Doc Derivation)
+ Distribution.Nixpkgs.Haskell.BuildInfo: instance Control.Lens.Each.Each Distribution.Nixpkgs.Haskell.BuildInfo.BuildInfo Distribution.Nixpkgs.Haskell.BuildInfo.BuildInfo (Data.Set.Internal.Set Language.Nix.Binding.Binding) (Data.Set.Internal.Set Language.Nix.Binding.Binding)
+ Distribution.Nixpkgs.Haskell.PackageSourceSpec: getPackage' :: Bool -> HackageDB -> Source -> IO Package
+ Distribution.Nixpkgs.Haskell.PackageSourceSpec: loadHackageDB :: Maybe FilePath -> Maybe UTCTime -> IO HackageDB

Files

cabal2nix.cabal view
@@ -1,9 +1,11 @@--- This file has been generated from package.yaml by hpack version 0.18.1.+-- This file has been generated from package.yaml by hpack version 0.21.2. -- -- see: https://github.com/sol/hpack+--+-- hash: d8202a64b33d8fbb627b568af818cd121aecd00f917af6b899cf9b07c48fa55a  name:           cabal2nix-version:        2.7+version:        2.7.1 synopsis:       Convert Cabal files into Nix build instructions. description:    Convert Cabal files into Nix build instructions. Users of Nix can install the latest version by running:                 .@@ -17,10 +19,13 @@                 Benno Fünfstück,                 Mateusz Kowalczyk,                 Michael Alan Dorman,+                Tom Smalley,                 Mathijs Kwik,                 Shea Levy,                 Dmitry Malikov,                 Eric Seidel,+                Jacob Mitchell,+                Graham Christensen,                 Hamish Mackenzie,                 Nikolay Amiantov,                 Aycan iRiCAN,@@ -32,32 +37,42 @@                 Tom Hunger,                 William Casarin,                 koral,+                ksaric,                 Adam Vogt,                 Alexey Shmalko,                 Corey O'Connor,                 Cray Elliott,+                David Johnson,+                Dmitry Bushev,+                Domen Kožar,                 Felix Kunzmann,                 Gabriel Ebner,                 Gergely Risko,-                Jacob Mitchell,                 Joachim Fasting,                 John Albietz,                 John Chee,                 Jussi Maki,+                Lisanna Dettwyler,                 Mark Laws,                 Mark Wotton,+                Matthew Pickering,                 Matthew Stewart,                 Matvey Aksenov,+                Nicholas Clarke,                 Nicolas Rolland,                 Oliver Charles,                 Pascal Wittmann,                 Patrick John Wheeler,+                Phil de Joux,+                Piotr Bogdan,                 Profpatsch,                 Raymond Gauthier,                 Renzo Carbonara,                 Rodney Lorrimar,                 Sibi,+                Sukant Hajra,                 Tanner Doshier,+                Vaibhav Sagar,                 Viktar Basharymau,                 danbst,                 karsten gebbert,@@ -68,7 +83,7 @@ license-file:   LICENSE tested-with:    GHC > 7.10 && < 8.3 build-type:     Custom-cabal-version:  >= 1.10+cabal-version:  >= 1.24  extra-source-files:     README.md@@ -79,9 +94,9 @@  custom-setup   setup-depends:-      base >= 4 && <5-    , Cabal-    , cabal-doctest >= 1 && <1.1+      Cabal+    , base >=4 && <5+    , cabal-doctest >=1 && <1.1  library   hs-source-dirs:@@ -89,23 +104,23 @@   other-extensions: CPP DeriveGeneric FlexibleInstances MultiParamTypeClasses OverloadedStrings RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell   ghc-options: -Wall   build-depends:-      aeson+      Cabal >2+    , aeson     , ansi-wl-pprint-    , base < 5+    , base <5     , bytestring-    , Cabal > 2     , containers-    , deepseq >= 1.4+    , deepseq >=1.4     , directory-    , distribution-nixpkgs >= 1.1+    , distribution-nixpkgs >=1.1     , filepath-    , hackage-db > 2-    , hopenssl >= 2+    , hackage-db >2+    , hopenssl >=2     , hpack     , language-nix     , lens     , optparse-applicative-    , pretty >= 1.1.2+    , pretty >=1.1.2     , process     , split     , text@@ -139,30 +154,30 @@       cabal2nix   ghc-options: -Wall   build-depends:-      aeson+      Cabal >2+    , aeson     , ansi-wl-pprint-    , base < 5+    , base <5     , bytestring-    , Cabal > 2+    , cabal2nix     , containers-    , deepseq >= 1.4+    , deepseq >=1.4     , directory-    , distribution-nixpkgs >= 1.1+    , distribution-nixpkgs >=1.1     , filepath-    , hackage-db > 2-    , hopenssl >= 2+    , hackage-db >2+    , hopenssl >=2     , hpack     , language-nix     , lens     , optparse-applicative-    , pretty >= 1.1.2+    , pretty >=1.1.2     , process     , split     , text     , time     , transformers     , yaml-    , cabal2nix   other-modules:       Paths_cabal2nix   default-language: Haskell2010@@ -173,35 +188,34 @@       hackage2nix   ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N   build-depends:-      aeson+      Cabal >2+    , aeson     , ansi-wl-pprint-    , base < 5+    , base <5     , bytestring-    , Cabal > 2+    , cabal2nix     , containers-    , deepseq >= 1.4+    , deepseq >=1.4     , directory-    , distribution-nixpkgs >= 1.1+    , distribution-nixpkgs >=1.1     , filepath-    , hackage-db > 2-    , hopenssl >= 2+    , hackage-db >2+    , hopenssl >=2     , hpack     , language-nix     , lens+    , monad-par+    , monad-par-extras+    , mtl     , optparse-applicative-    , pretty >= 1.1.2+    , pretty >=1.1.2     , process     , split     , text     , time     , transformers-    , yaml-    , cabal2nix-    , monad-par-    , monad-par-extras-    , mtl-    , time     , utf8-string+    , yaml   other-modules:       Paths_cabal2nix       HackageGit@@ -210,32 +224,34 @@ test-suite doctests   type: exitcode-stdio-1.0   main-is: doctests.hs+  other-modules:+      Paths_cabal2nix   hs-source-dirs:       test   ghc-options: -Wall -threaded   build-depends:-      aeson+      Cabal >2+    , aeson     , ansi-wl-pprint-    , base < 5+    , base <5     , bytestring-    , Cabal > 2     , containers-    , deepseq >= 1.4+    , deepseq >=1.4     , directory-    , distribution-nixpkgs >= 1.1+    , distribution-nixpkgs >=1.1+    , doctest     , filepath-    , hackage-db > 2-    , hopenssl >= 2+    , hackage-db >2+    , hopenssl >=2     , hpack     , language-nix     , lens     , optparse-applicative-    , pretty >= 1.1.2+    , pretty >=1.1.2     , process     , split     , text     , time     , transformers     , yaml-    , doctest   default-language: Haskell2010
src/Cabal2nix.hs view
@@ -2,13 +2,14 @@ {-# LANGUAGE OverloadedStrings #-}  module Cabal2nix-  ( main, cabal2nix, cabal2nix'+  ( main, cabal2nix, cabal2nix', cabal2nixWithDB   )   where  import Control.Exception ( bracket ) import Control.Lens-import Data.Maybe ( fromMaybe )+import Control.Monad ( when )+import Data.Maybe ( fromMaybe, isJust ) import Data.Monoid ( (<>) ) import qualified Data.Set as Set import Data.String@@ -29,9 +30,10 @@ import Options.Applicative import Paths_cabal2nix ( version ) import System.Environment ( getArgs )-import System.IO ( hFlush, stdout, stderr )+import System.IO ( hFlush, hPutStrLn, stdout, stderr ) import qualified Text.PrettyPrint.ANSI.Leijen as P2 hiding ( (<$>), (<>) ) import Text.PrettyPrint.HughesPJClass ( Doc, Pretty(..), text, vcat, hcat, semi )+import qualified Distribution.Nixpkgs.Haskell.Hackage as DB  data Options = Options   { optSha256 :: Maybe String@@ -138,10 +140,22 @@  cabal2nix' :: [String] -> IO (Either Doc Derivation) cabal2nix' args = do-  Options {..} <- handleParseResult $ execParserPure defaultPrefs pinfo args+  opts@Options {..} <- handleParseResult $ execParserPure defaultPrefs pinfo args    pkg <- getPackage optHpack optHackageDb optHackageSnapshot $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)+  processPackage opts pkg +cabal2nixWithDB :: DB.HackageDB -> [String] -> IO (Either Doc Derivation)+cabal2nixWithDB db args = do+  opts@Options {..} <- handleParseResult $ execParserPure defaultPrefs pinfo args+  when (isJust optHackageDb) $ hPutStrLn stderr "WARN: HackageDB provided directly; ignoring --hackage-db"+  when (isJust optHackageSnapshot) $ hPutStrLn stderr "WARN: HackageDB provided directly; ignoring --hackage-snapshot"++  pkg <- getPackage' optHpack db $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)+  processPackage opts pkg++processPackage :: Options -> Package -> IO (Either Doc Derivation)+processPackage Options{..} pkg = do   let       withHpackOverrides :: Derivation -> Derivation       withHpackOverrides = if pkgRanHpack pkg then hpackOverrides else id
src/Distribution/Nixpkgs/Haskell/FromCabal.hs view
@@ -22,8 +22,10 @@ import Distribution.Package import Distribution.PackageDescription import qualified Distribution.PackageDescription as Cabal+import Distribution.Types.ExeDependency as Cabal import Distribution.Types.LegacyExeDependency as Cabal import Distribution.Types.PkgconfigDependency as Cabal+import Distribution.Types.UnqualComponentName as Cabal import Distribution.PackageDescription.Configuration as Cabal import Distribution.Types.ComponentRequestedSpec as Cabal import Distribution.System@@ -64,14 +66,14 @@     Right (d,_)  -> (d,[])  fromPackageDescription :: HaskellResolver -> NixpkgsResolver -> [Dependency] -> FlagAssignment -> PackageDescription -> Derivation-fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags (PackageDescription {..}) = normalize $ postProcess $ nullDerivation+fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags PackageDescription {..} = normalize $ postProcess $ nullDerivation     & isLibrary .~ isJust library     & pkgid .~ package     & revision .~ xrev     & isLibrary .~ isJust library     & isExecutable .~ not (null executables)     & extraFunctionArgs .~ mempty-    & libraryDepends .~ maybe mempty (convertBuildInfo . libBuildInfo) library+    & libraryDepends .~ foldMap (convertBuildInfo . libBuildInfo) (maybeToList library ++ subLibraries)     & executableDepends .~ mconcat (map (convertBuildInfo . buildInfo) executables)     & testDepends .~ mconcat (map (convertBuildInfo . testBuildInfo) testSuites)     & benchmarkDepends .~ mconcat (map (convertBuildInfo . benchmarkBuildInfo) benchmarks)@@ -124,12 +126,16 @@     resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion) = resolveInHackage i                                   | otherwise = resolveInNixpkgs i +    internalLibNames :: [PackageName]+    internalLibNames = fmap unqualComponentNameToPackageName . catMaybes $ libName <$> subLibraries+     convertBuildInfo :: Cabal.BuildInfo -> Nix.BuildInfo     convertBuildInfo Cabal.BuildInfo {..} = mempty-      & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _) <- targetBuildDepends ]+      & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _) <- targetBuildDepends, x `notElem` internalLibNames ]       & system .~ Set.fromList [ resolveInNixpkgs y | x <- extraLibs, y <- libNixName x ]       & pkgconfig .~ Set.fromList [ resolveInNixpkgs y | PkgconfigDependency x _ <- pkgconfigDepends, y <- libNixName (unPkgconfigName x) ]-      & tool .~ Set.fromList [ resolveInHackageThenNixpkgs y | LegacyExeDependency x _ <- buildTools, y <- buildToolNixName x ]+      & tool .~ Set.fromList (map resolveInHackageThenNixpkgs . concatMap buildToolNixName+              $ [ unPackageName x | ExeDependency x _ _ <- buildToolDepends ] ++ [ x | LegacyExeDependency x _ <- buildTools ])      convertSetupBuildInfo :: Cabal.SetupBuildInfo -> Nix.BuildInfo     convertSetupBuildInfo bi = mempty
src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs view
@@ -12,6 +12,7 @@ configureCabalFlags (PackageIdentifier name version)  | name == "accelerate-examples"= [disable "opencl"]  | name == "arithmoi"           = [disable "llvm"]+ | name == "cassava"            = [disable "bytestring--lt-0_10_4"]  | name == "darcs"              = [enable "library", enable "force-char8-encoding"]  | name == "diagrams-builder"   = [enable "cairo", enable "svg", enable "ps", enable "rasterific"]  | name == "folds"              = [disable "test-hlint"]@@ -28,7 +29,7 @@                                   , enable "s3"                                   , enable "tahoe"                                   , enable "tdfa"-                                  , ("testsuite", version `withinRange` "< 6.20170925")+                                  , ("testsuite", version `withinRange` "< 6.20170925 || >= 6.20171214")                                   , enable "torrentparser"                                   , enable "webapp"                                   , enable "webapp-secure"
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs view
@@ -61,7 +61,7 @@   , ("gi-pangocairo", giCairoPhaseOverrides)                     -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("gi-pango", giCairoPhaseOverrides)                     -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("git-annex", gitAnnexHook)-  , ("git-annex >= 6.20170925", set doCheck False)      -- new version of git-annex require their test suite to be run inside of a git checkout+  , ("git-annex >= 6.20170925 && < 6.20171214", set doCheck False)      -- some versions of git-annex require their test suite to be run inside of a git checkout   , ("github-backup", set (executableDepends . tool . contains (pkg "git")) True)   , ("git", set doCheck False)          -- https://github.com/vincenthz/hit/issues/33   , ("gi-webkit", webkitgtk24xHook)   -- https://github.com/haskell-gi/haskell-gi/issues/36@@ -79,7 +79,8 @@   , ("holy-project", set doCheck False)         -- attempts to access the network   , ("hoogle", set testTarget "--test-option=--no-net")   , ("hsignal < 0.2.7.4", set phaseOverrides "prePatch = \"rm -v Setup.lhs\";") -- https://github.com/amcphail/hsignal/issues/1-  , ("hslua", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_1")))+  , ("hslua < 0.9.3", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_1")))+  , ("hslua >= 0.9.3", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_3")))   , ("http-client-openssl >= 0.2.0.1", set doCheck False) -- attempts to access the network   , ("http-client", set doCheck False)          -- attempts to access the network   , ("http-client-tls >= 0.2.2", set doCheck False) -- attempts to access the network
src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs view
@@ -1,5 +1,5 @@ module Distribution.Nixpkgs.Haskell.PackageSourceSpec-  ( Package(..), getPackage, sourceFromHackage+  ( Package(..), getPackage, getPackage', loadHackageDB, sourceFromHackage   ) where  import qualified Control.Exception as Exception@@ -43,20 +43,26 @@            -> Source            -> IO Package getPackage optHpack optHackageDB optHackageSnapshot source = do-  (derivSource, ranHpack, pkgDesc) <- fetchOrFromDB optHpack optHackageDB optHackageSnapshot source+  hackageDB <- loadHackageDB optHackageDB optHackageSnapshot+  getPackage' optHpack hackageDB source++getPackage' :: Bool+            -- ^ Whether hpack should regenerate the cabal file.+            -> DB.HackageDB+            -> Source+            -> IO Package+getPackage' optHpack hackageDB source = do+  (derivSource, ranHpack, pkgDesc) <- fetchOrFromDB optHpack hackageDB source   (\s -> Package s ranHpack pkgDesc) <$> maybe (sourceFromHackage (sourceHash source) (showPackageIdentifier pkgDesc) $ sourceCabalDir source) return derivSource  fetchOrFromDB :: Bool               -- ^ Whether hpack should regenerate the cabal file-              -> Maybe FilePath-              -- ^ The path to the Hackage database.-              -> Maybe UTCTime-              -- ^ If we have hackage-snapshot time.+              -> DB.HackageDB               -> Source               -> IO (Maybe DerivationSource, Bool, Cabal.GenericPackageDescription)-fetchOrFromDB optHpack optHackageDB optHackageSnapshot src+fetchOrFromDB optHpack hackageDB src   | "cabal://" `isPrefixOf` sourceUrl src = do-      (msrc, pkgDesc) <- fromDB optHackageDB optHackageSnapshot . drop (length "cabal://") $ sourceUrl src+      (msrc, pkgDesc) <- fromDB hackageDB . drop (length "cabal://") $ sourceUrl src       return (msrc, False, pkgDesc)   | otherwise                             = do     r <- fetch (\dir -> cabalFromPath optHpack (dir </> sourceCabalDir src)) src@@ -65,14 +71,20 @@       Just (derivSource, (externalSource, ranHpack, pkgDesc)) -> do         return (derivSource <$ guard externalSource, ranHpack, pkgDesc) -fromDB :: Maybe FilePath-       -> Maybe UTCTime+loadHackageDB :: Maybe FilePath+              -- ^ The path to the Hackage database.+              -> Maybe UTCTime+              -- ^ If we have hackage-snapshot time.+              -> IO DB.HackageDB+loadHackageDB optHackageDB optHackageSnapshot = do+  dbPath <- maybe DB.hackageTarball return optHackageDB+  DB.readTarball optHackageSnapshot dbPath++fromDB :: DB.HackageDB        -> String        -> IO (Maybe DerivationSource, Cabal.GenericPackageDescription)-fromDB optHackageDB optHackageSnapshot pkg = do-  dbPath <- maybe DB.hackageTarball return optHackageDB-  db <- DB.readTarball optHackageSnapshot dbPath-  vd <- maybe unknownPackageError return (DB.lookup name db >>= lookupVersion)+fromDB hackageDB pkg = do+  vd <- maybe unknownPackageError return (DB.lookup name hackageDB >>= lookupVersion)   let ds = case DB.tarballSha256 vd of              Nothing -> Nothing              Just hash -> Just (DerivationSource "url" url "" hash)@@ -82,7 +94,7 @@   pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParse pkg)   name = Cabal.packageName pkgId -  unknownPackageError = fail "No such package in the cabal database. Did you run cabal update?"+  unknownPackageError = fail $ "No such package " ++ display pkgId ++ " in the cabal database. Did you run cabal update?"    url = "mirror://hackage/" ++ display pkgId ++ ".tar.gz"