Skip to content

Commit

Permalink
hackage2nix: the 'broken-packages' section now contains versioned pac…
Browse files Browse the repository at this point in the history
…kage names
  • Loading branch information
peti committed Apr 15, 2019
1 parent c57cbfc commit e08962a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hackage2nix/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ main = do
let isInDefaultPackageSet, isHydraEnabled, isBroken :: Bool
isInDefaultPackageSet = (== Just v) (Map.lookup name generatedDefaultPackageSet)
isHydraEnabled = isInDefaultPackageSet && not (isBroken || name `Set.member` dontDistributePackages config)
isBroken = name `Set.member` brokenPackages config
isBroken = any (withinRange v) [ vr | Dependency pn vr <- brokenPackages config, pn == name ]

droppedPlatforms :: Set Platform
droppedPlatforms = Map.findWithDefault mempty name (unsupportedPlatforms config)
Expand Down
10 changes: 4 additions & 6 deletions src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module Distribution.Nixpkgs.Haskell.FromCabal.Configuration
)
where

import Control.Exception ( throwIO )
import Control.DeepSeq
import Control.Exception ( throwIO )
import Control.Lens
import Control.Monad
import Data.Aeson
Expand Down Expand Up @@ -57,7 +57,7 @@ data Configuration = Configuration
-- |We know that these packages won't compile, so we mark them as broken and
-- also disable their meta.hydraPlatforms attribute to avoid cluttering our
-- Hydra job with lots of failure messages.
, brokenPackages :: Set PackageName
, brokenPackages :: [Constraint]
}
deriving (Show, Generic)

Expand Down Expand Up @@ -89,15 +89,13 @@ parseKey :: FromJSON k => Text -> k
parseKey s = either error id (parseEither parseJSON (String s))

readConfiguration :: FilePath -> IO Configuration
readConfiguration path =
decodeFileEither path >>= either throwIO assertConsistency
readConfiguration path = decodeFileEither path >>= either throwIO assertConsistency

assertConsistency :: Monad m => Configuration -> m Configuration
assertConsistency cfg@Configuration {..} = do
let report msg = fail ("*** configuration error: " ++ msg)

maintainedPackages = Set.unions (Map.elems packageMaintainers)
disabledPackages = dontDistributePackages `Set.union` brokenPackages
disabledPackages = dontDistributePackages `Set.union` Set.fromList (depPkgName <$> brokenPackages)
disabledMaintainedPackages = maintainedPackages `Set.intersection` disabledPackages
unless (Set.null disabledMaintainedPackages) $
report ("disabled packages that have a maintainer: " ++ show disabledMaintainedPackages)
Expand Down
4 changes: 4 additions & 0 deletions src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ instance FromJSON PackageIdentifier where
parseJSON (String s) = return (fromString (T.unpack s))
parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell package identifier")

instance FromJSON VersionRange where
parseJSON (String s) = return (fromString (T.unpack s))
parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Cabal VersionRange")

instance FromJSON Dependency where
parseJSON (String s) = return (fromString (T.unpack s))
parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Haskell Dependency")
Expand Down

0 comments on commit e08962a

Please sign in to comment.