packages feed

cabal2nix 2.0.1 → 2.0.2

raw patch · 7 files changed

+40/−184 lines, 7 filesdep −stackage-typesdep ~aesonPVP ok

version bump matches the API change (PVP)

Dependencies removed: stackage-types

Dependency ranges changed: aeson

API changes (from Hackage documentation)

Files

cabal2nix.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           cabal2nix-version:        2.0.1+version:        2.0.2 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:                 .@@ -70,7 +70,7 @@       src   ghc-options: -Wall   build-depends:-      aeson < 1+      aeson     , ansi-wl-pprint     , base < 5     , bytestring@@ -117,7 +117,7 @@       cabal2nix   ghc-options: -Wall   build-depends:-      aeson < 1+      aeson     , ansi-wl-pprint     , base < 5     , bytestring@@ -149,7 +149,7 @@       hackage2nix   ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N   build-depends:-      aeson < 1+      aeson     , ansi-wl-pprint     , base < 5     , bytestring@@ -174,11 +174,9 @@     , monad-par     , monad-par-extras     , mtl-    , stackage-types     , time     , utf8-string   other-modules:       Paths_cabal2nix       HackageGit-      Stackage   default-language: Haskell2010
hackage2nix/Main.hs view
@@ -3,6 +3,8 @@  module Main ( main ) where +import HackageGit+ import Control.Lens import Control.Monad import Control.Monad.Par.Combinator@@ -29,11 +31,9 @@ import Distribution.System import Distribution.Text import Distribution.Version-import HackageGit import Language.Nix import Options.Applicative import qualified Paths_cabal2nix as Main-import Stackage import System.FilePath import System.IO import Text.PrettyPrint.HughesPJClass hiding ( (<>) )@@ -45,8 +45,6 @@   { hackageRepository :: FilePath   , preferredVersionsFile :: Maybe FilePath   , nixpkgsRepository :: FilePath-  , ltsHaskellRepository :: FilePath-  , stackageNightlyRepository :: FilePath   , configFile :: FilePath   , targetPlatform :: Platform   }@@ -59,8 +57,6 @@         <$> strOption (long "hackage" <> help "path to Hackage git repository" <> value "hackage" <> showDefaultWith id <> metavar "PATH")         <*> optional (strOption (long "preferred-versions" <> help "path to Hackage preferred-versions file" <> value "hackage/preferred-versions" <> showDefault <> metavar "PATH"))         <*> strOption (long "nixpkgs" <> help "path to Nixpkgs repository" <> value "nixpkgs" <> showDefaultWith id <> metavar "PATH")-        <*> strOption (long "lts-haskell" <> help "path to LTS Haskell repository" <> value "lts-haskell" <> showDefaultWith id <> metavar "PATH")-        <*> strOption (long "stackage-nightly" <> help "path to Stackage Nightly repository" <> value "stackage-nightly" <> showDefaultWith id <> metavar "PATH")         <*> strOption (long "config" <> help "path to configuration file inside of Nixpkgs" <> value "pkgs/development/haskell-modules/configuration-hackage2nix.yaml" <> showDefaultWith id <> metavar "PATH")         <*> option (fmap fromString str) (long "platform" <> help "target platform to generate package set for" <> value "x86_64-linux" <> showDefaultWith display <> metavar "PLATFORM") @@ -75,19 +71,14 @@               )   CLI {..} <- execParser pinfo -  config' <- readConfiguration (nixpkgsRepository </>  configFile)+  config <- readConfiguration (nixpkgsRepository </>  configFile)   nixpkgs <- readNixpkgPackageMap nixpkgsRepository Nothing   preferredVersions <- readPreferredVersions (fromMaybe (hackageRepository </> "preferred-versions") preferredVersionsFile)   let fixup = Map.delete "acme-everything"      -- TODO: https://github.com/NixOS/cabal2nix/issues/164             . Map.delete "som"                  -- TODO: https://github.com/NixOS/cabal2nix/issues/164             . Map.delete "type"                 -- TODO: https://github.com/NixOS/cabal2nix/issues/163   hackage <- fixup <$> readHackage hackageRepository-  lts <- readLTSHaskell ltsHaskellRepository-  nightly <- readStackageNightly stackageNightlyRepository   let-      config :: Configuration-      config = config' { defaultPackageOverrides = [ Dependency n (thisVersion (Stackage.version spec)) | (n, spec) <- Map.toList (packages nightly) ] }-       hackagePackagesFile :: FilePath       hackagePackagesFile = nixpkgsRepository </> "pkgs/development/haskell-modules/hackage-packages.nix" @@ -113,15 +104,11 @@       extraPackageSet = Map.unionsWith Set.union                           [ Map.singleton name (Set.singleton (resolveConstraint c hackage)) | c@(Dependency name _) <- extraPackages config ] -      stackagePackageSet :: Map PackageName (Map Version Spec)-      stackagePackageSet = Map.fromListWith (Map.unionWith mergeSpecs) [ (n, Map.singleton (Stackage.version spec) spec) | snapshot <- [nightly,lts], (n, spec) <- Map.toList (packages snapshot) ]-       db :: PackageMultiSet       db = Map.unionsWith Set.union [ Map.map Set.singleton generatedDefaultPackageSet                                     , Map.map Set.singleton latestCorePackageSet                                     , Map.map Set.singleton latestOverridePackageSet                                     , extraPackageSet-                                    , Map.map Map.keysSet stackagePackageSet                                     ]        haskellResolver :: Dependency -> Bool@@ -151,9 +138,6 @@           tarballSHA256 = fromMaybe (error (display pkgId ++ ": meta data has no hash for the tarball"))                                     (view (hashes . at "SHA256") meta) -          spec :: Spec-          spec = Spec v True True `fromMaybe` (Map.lookup name stackagePackageSet >>= Map.lookup v)-           flagAssignment :: FlagAssignment                  -- We don't use the flags from Stackage Nightly here, because           flagAssignment = configureCabalFlags pkgId        -- they are chosen specifically for GHC 7.10.2. @@ -164,8 +148,6 @@           drv = fromGenericPackageDescription haskellResolver nixpkgsResolver targetPlatform (compilerInfo config) flagAssignment [] descr                   & src .~ DerivationSource "url" ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") "" tarballSHA256                   & editedCabalFile .~ cabalSHA256-                  & Derivation.runHaddock &&~ Stackage.runHaddock spec-                  & doCheck &&~ runTests spec                   & metaSection.hydraPlatforms %~ (`Set.difference` Map.findWithDefault Set.empty name (dontDistributePackages config))                   & metaSection.maintainers .~ Map.findWithDefault Set.empty name globalPackageMaintainers                   & metaSection.hydraPlatforms %~ (if isInDefaultPackageSet then id else const Set.empty)@@ -186,47 +168,6 @@     hPutStrLn h ""     mapM_ (\pkg -> hPutStrLn h pkg >> hPutStrLn h "") pkgs     hPutStrLn h "}"--  forM_ [lts] $ \Snapshot {..} -> liftIO $ do-     let allPackages :: PackageSet-         allPackages = Map.difference-                         (Map.fromList [ (name, Stackage.version spec) | (name, spec) <- Map.toList packages ] `Map.union` generatedDefaultPackageSet)-                         corePackages'--         ltsConfigFile :: FilePath-         ltsConfigFile = nixpkgsRepository </> "pkgs/development/haskell-modules/configuration-lts.nix"--         corePackages' :: PackageSet-         corePackages' = corePackages `Map.union` Map.fromList [("Cabal", Version [] []), ("rts", Version [] [])]--     withFile ltsConfigFile WriteMode $ \h -> do-       hPutStrLn h "{ pkgs }:"-       hPutStrLn h ""-       hPutStrLn h "with import ./lib.nix { inherit pkgs; };"-       hPutStrLn h ""-       hPutStrLn h "self: super: {"-       hPutStrLn h ""-       hPutStrLn h "  # core libraries provided by the compiler"-       forM_ (Map.keys corePackages') $ \n ->-         unless (n == "ghc") (hPutStrLn h ("  " ++ unPackageName n ++ " = null;"))-       hPutStrLn h ""-       hPutStrLn h ("  # " ++ show (pPrint snapshot) ++ " packages")-       forM_ (Map.toList allPackages) $ \(name, v) -> do-         let pkgId = PackageIdentifier name v--             isInDefaultPackageSet :: Bool-             isInDefaultPackageSet = maybe False (== v) (Map.lookup name generatedDefaultPackageSet)--             isInStackage :: Bool-             isInStackage = isJust (Map.lookup name packages)-         case (isInStackage,isInDefaultPackageSet) of-           (True,True)   -> return ()           -- build is visible and enabled-           (True,False)  -> hPutStrLn h ("  " ++ show (unPackageName name) ++ " = doDistribute super." ++ show (mangle pkgId) ++ ";")-           (False,True)  -> hPutStrLn h ("  " ++ show (unPackageName name) ++ " = dontDistribute super." ++ show (unPackageName name) ++ ";")-           (False,False) -> fail ("logic error processing " ++ display pkgId ++ " in " ++  show (pPrint snapshot))-       hPutStrLn h ""-       hPutStrLn h "}"-  isFromHackage :: Binding -> Bool isFromHackage b = case view (reference . path) b of
− hackage2nix/Stackage.hs
@@ -1,106 +0,0 @@-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE StandaloneDeriving #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}--module Stackage where--import Control.Exception ( assert )-import Control.Monad-import Control.Monad.Trans-import Data.List-import Data.List.Split-import Data.Map as Map-import Data.Maybe-import Data.Time.Calendar-import Data.Yaml-import Distribution.Compiler-import Distribution.Package-import Distribution.Version-import GHC.Generics ( Generic )-import Stackage.Types hiding ( display )-import System.Directory-import System.FilePath-import Text.PrettyPrint.HughesPJClass--data Spec = Spec-            { version :: Version-  --        , flagOverrides :: Map FlagName Bool-            , runTests :: Bool-            , runHaddock :: Bool-  --        , runLinuxBuilds :: Bool-            }-  deriving (Show, Generic)--instance Eq Spec where-  a == b = version a == version b--instance Ord Spec where-  compare a b = compare (version a) (version b)--data Snapshot = Snapshot-            { snapshot :: SnapshotType-            , compiler :: CompilerId-            , corePackages :: Map PackageName Version-            , packages :: Map PackageName Spec-            }-  deriving (Show)--instance Pretty SnapshotType where-  pPrint STNightly = text "stackage-nightly"-  pPrint (STNightly2 _) = text "stackage-nightly"-  pPrint (STLTS m n) = text "lts-" <> int m <> char '.' <> int n--readLTSHaskell :: FilePath -> IO Snapshot-readLTSHaskell dirPath = do-  filePaths <- liftIO (listFiles dirPath)-  let latest = maximum (Prelude.filter (\p -> takeExtension p == ".yaml") filePaths)-  readSnapshot (dirPath </> latest)--readStackageNightly :: FilePath -> IO Snapshot-readStackageNightly dirPath = do-  filePaths <- liftIO (listFiles dirPath)-  let filePath = maximum [ p | p <- filePaths, takeExtension p == ".yaml" ]-  readSnapshot (dirPath </> filePath)--readSnapshot :: FilePath -> IO Snapshot-readSnapshot p = fmap (fromBuildPlan (parseSnapshotType (takeFileName p))) (readBuildPlan p)--parseSnapshotType :: FilePath -> SnapshotType-parseSnapshotType p-  | "lts-" `isPrefixOf` p-  , [major,minor] <- splitOn "." (drop 4 (dropExtension p))-                = STLTS (read major) (read minor)-  | "nightly-" `isPrefixOf` p-  , [year,month,day] <- splitOn "-" (drop 8 (dropExtension p))-                = STNightly2 (fromGregorian (read year) (read month) (read day))-  | otherwise   = error ("parseSnapshotType: invalid file name " ++ p)--readBuildPlan :: FilePath -> IO BuildPlan-readBuildPlan = fmap fromJust . decodeFile--fromBuildPlan :: SnapshotType -> BuildPlan -> Snapshot-fromBuildPlan snt bp = Snapshot snt-                                (CompilerId GHC (siGhcVersion (bpSystemInfo bp)))-                                (siCorePackages (bpSystemInfo bp))-                                (Map.map fromPackagePlan (bpPackages bp))--fromPackagePlan :: PackagePlan -> Spec-fromPackagePlan pp = Spec (ppVersion pp)-    --                    (pcFlagOverrides ppc)-                          (pcTests ppc == ExpectSuccess)-                          (pcHaddocks ppc == ExpectSuccess)-    --                    (not (pcSkipBuild ppc))-  where ppc = ppConstraints pp--listFiles :: FilePath -> IO [FilePath]-listFiles path = do-  let isFile p = doesFileExist (path </> p)-  getDirectoryContents path >>= filterM isFile . Prelude.filter (\x -> head x /= '.')--mergeSpecs :: Spec -> Spec -> Spec-mergeSpecs a b = Spec { version = assert (version a == version b) version a-         --           , flagOverrides = flagOverrides a-                      , runTests = runTests a && runTests b-                      , runHaddock = runHaddock a && runHaddock b-         --           , runLinuxBuilds = runLinuxBuilds a-                      }
src/Distribution/Nixpkgs/Haskell/FromCabal.hs view
@@ -110,7 +110,7 @@                        | otherwise = binding # (i, path # ["self",i])   -- TODO: "self" shouldn't be hardcoded.      goodScopes :: Set [Identifier]-    goodScopes = Set.fromList (map ("pkgs":) [[], ["xorg"], ["xlibs"], ["gnome"], ["gnome3"], ["kde4"]])+    goodScopes = Set.fromList (map ("pkgs":) [[], ["xorg"], ["xlibs"], ["gnome2"], ["gnome3"], ["kde4"]])      resolveInNixpkgs :: Identifier -> Binding     resolveInNixpkgs i
src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE CPP               #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveGeneric #-}@@ -10,6 +10,7 @@ import Control.DeepSeq import Control.Lens import Control.Monad+import Data.Aeson import Data.Map as Map import Data.Set as Set import Data.Text as T@@ -65,24 +66,31 @@   parseJSON (String s) = pure (review ident (T.unpack s))   parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier") --- aeson-0.11 introduces a general instance, so we just need a couple--- of specific ones-#if MIN_VERSION_aeson(0,11,0)+#if MIN_VERSION_aeson(1,0,0)++instance FromJSONKey Identifier where+  fromJSONKey = FromJSONKeyText parseKey++instance FromJSONKey PackageName where+  fromJSONKey = FromJSONKeyText parseKey++#elif MIN_VERSION_aeson(0,11,0)+ instance (FromJSON v) => FromJSON (Map Identifier v) where   parseJSON = fmap (Map.mapKeys parseKey) . parseJSON  instance (FromJSON v) => FromJSON (Map PackageName v) where   parseJSON = fmap (Map.mapKeys parseKey) . parseJSON -parseKey :: (FromJSON k) => Text -> k-parseKey s = either error id (parseEither parseJSON (String s)) #else+ instance (Ord k, FromJSON k, FromJSON v) => FromJSON (Map k v) where   parseJSON  = fmap (Map.mapKeys parseKey) . parseJSON-    where-      parseKey :: FromJSON k => Text -> k-      parseKey s = either error id (parseEither parseJSON (String s))+ #endif++parseKey :: FromJSON k => Text -> k+parseKey s = either error id (parseEither parseJSON (String s))  readConfiguration :: FilePath -> IO Configuration readConfiguration path =
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs view
@@ -96,6 +96,7 @@ libNixName "llvm-3.5"                           = return "llvm" libNixName "llvm-3.6"                           = return "llvm" libNixName "llvm-3.7"                           = return "llvm"+libNixName "llvm-3.8"                           = return "llvm" libNixName "libavutil"                          = return "ffmpeg" libNixName "libglade-2.0"                       = return "libglade" libNixName "libgsasl"                           = return "gsasl"@@ -128,6 +129,7 @@ libNixName "portaudio-2.0"                      = return "portaudio" libNixName "pq"                                 = return "postgresql" libNixName "pthread"                            = []+libNixName "pulse"                              = return "libpulseaudio" libNixName "pulse-simple"                       = return "libpulseaudio" libNixName "python-3.3"                         = return "python33" libNixName "python-3.4"                         = return "python34"
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs view
@@ -56,6 +56,10 @@   , ("gi-gio", giPhaseOverrides)                            -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("gi-glib", giPhaseOverrides)                           -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("gi-gobject", giPhaseOverrides)                        -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-gst", gstLibOverrides)                             -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-gstaudio", gstLibAudioOverrides)                   -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-gstbase", gstLibAudioOverrides)                    -- https://github.com/haskell-gi/haskell-gi/issues/36+  , ("gi-gstvideo", gstLibAudioOverrides)                   -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("gi-gtk", giGtkPhaseOverrides)                         -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("gi-javascriptcore", giJavascriptCorePhaseOverrides)   -- https://github.com/haskell-gi/haskell-gi/issues/36   , ("gi-pango", giPhaseOverrides)                          -- https://github.com/haskell-gi/haskell-gi/issues/36@@ -265,6 +269,15 @@ giGdkPhaseOverrides :: Derivation -> Derivation giGdkPhaseOverrides   = set phaseOverrides ("preConfigure = ''" ++ exportGirSearchPath ["gtk3.dev"] ++ "'';")++gstLibOverrides :: Derivation -> Derivation+gstLibOverrides+  = over (libraryDepends . pkgconfig) (replace (pkg "gstreamer") "gstreamer = pkgs.gst_all_1.gstreamer")++gstLibAudioOverrides :: Derivation -> Derivation+gstLibAudioOverrides+  = over (libraryDepends . pkgconfig) (replace (pkg "gst_plugins_base") "gst_plugins_base = pkgs.gst_all_1.gst-plugins-base")+  . set (libraryDepends . system . contains (pkg "gobjectIntrospection")) True  giGdkPixBufPhaseOverrides :: Derivation -> Derivation giGdkPixBufPhaseOverrides