git.iko.soy/typeable/cabal2nix
on master help sign in
hackage2nix: extend the configuration file

We can now distinguish between ... (1) packages that are unsupported on certain platforms by design (i.e. because they target Microsoft Windows), (2) packages that we cannot distribute via Hydra at all (i.e. because they have an unfree license), (3) and packages that don't compile successfully. Case (1) is reflected in meta.platforms, (2) is reflected in meta.hydraPlatforms, and (3) affects meta.broken.

commitea0f0cabe2b0680ffbe382c2f0501ea0cb5c5c4b authorPeter Simons <simons@cryp.to> dateSat 16 Mar 2019, 11:08 (8 years ago) parenteabf258
2 files changed+27−10
hackage2nix/Main.hs+10−3 src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+17−7
hackage2nix/Main.hs+10−3
@@ -132,8 +132,13 @@ main = do
132132 (descr, cabalSHA256) <- readPackage hackageRepository pkgId
133133 meta <- readPackageMeta hackageRepository pkgId
134134
135− let isInDefaultPackageSet :: Bool
135+ let isInDefaultPackageSet, isHydraEnabled, isBroken :: Bool
136136 isInDefaultPackageSet = (== Just v) (Map.lookup name generatedDefaultPackageSet)
137+ isHydraEnabled = isInDefaultPackageSet && not (isBroken || name `Set.member` dontDistributePackages config)
138+ isBroken = name `Set.member` brokenPackages config
139+
140+ droppedPlatforms :: Set Platform
141+ droppedPlatforms = Map.findWithDefault mempty name (unsupportedPlatforms config)
137142
138143 tarballSHA256 :: SHA256Hash
139144 tarballSHA256 = fromMaybe (error (display pkgId ++ ": meta data has no hash for the tarball"))
@@ -149,9 +154,11 @@ main = do
149154 drv = fromGenericPackageDescription haskellResolver nixpkgsResolver targetPlatform (compilerInfo config) flagAssignment [] descr
150155 & src .~ urlDerivationSource ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") tarballSHA256
151156 & editedCabalFile .~ cabalSHA256
152− & metaSection.hydraPlatforms %~ (`Set.difference` Map.findWithDefault Set.empty name (dontDistributePackages config))
157+ & metaSection.platforms %~ (`Set.difference` Map.findWithDefault Set.empty name (unsupportedPlatforms config))
158+ & metaSection.hydraPlatforms %~ (if Set.null droppedPlatforms then id else (`Set.difference` droppedPlatforms))
159+ & metaSection.hydraPlatforms %~ (if isHydraEnabled then id else const Set.empty)
160+ & metaSection.broken ||~ isBroken
153161 & metaSection.maintainers .~ Map.findWithDefault Set.empty name globalPackageMaintainers
154− & metaSection.hydraPlatforms %~ (if isInDefaultPackageSet then id else const Set.empty)
155162 & metaSection.homepage .~ ""
156163
157164 overrides :: Doc
src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+17−7
@@ -42,14 +42,22 @@ data Configuration = Configuration
4242 -- role during dependency resolution.
4343 , extraPackages :: [Constraint]
4444
45− -- |We know that these packages won't build, so we give them an empty
46− -- meta.hydraPlatforms attribute to avoid cluttering our Hydra output with
47− -- lots of failure messages.
48− , dontDistributePackages :: Map PackageName (Set Platform)
49−
5045 -- |This information is used by the @hackage2nix@ utility to determine the
5146 -- 'maintainers' for a given Haskell package.
5247 , packageMaintainers :: Map Identifier (Set PackageName)
48+
49+ -- |These packages (by design) don't support certain platforms.
50+ , unsupportedPlatforms :: Map PackageName (Set Platform)
51+
52+ -- |These packages cannot be distributed by Hydra, i.e. because they have an
53+ -- unfree license or depend on other tools that cannot be distributed for
54+ -- some reason.
55+ , dontDistributePackages :: Set PackageName
56+
57+ -- |We know that these packages won't compile, so we mark them as broken and
58+ -- also disable their meta.hydraPlatforms attribute to avoid cluttering our
59+ -- Hydra job with lots of failure messages.
60+ , brokenPackages :: Set PackageName
5361 }
5462 deriving (Show, Generic)
5563
@@ -61,8 +69,10 @@ instance FromJSON Configuration where
6169 <*> o .:? "core-packages" .!= mempty
6270 <*> o .:? "default-package-overrides" .!= mempty
6371 <*> o .:? "extra-packages" .!= mempty
64− <*> o .:? "dont-distribute-packages" .!= mempty
6572 <*> o .:? "package-maintainers" .!= mempty
73+ <*> o .:? "unsupported-platforms" .!= mempty
74+ <*> o .:? "dont-distribute-packages" .!= mempty
75+ <*> o .:? "broken-packages" .!= mempty
6676 parseJSON _ = error "invalid Configuration"
6777
6878instance FromJSON Identifier where
@@ -87,7 +97,7 @@ assertConsistency cfg@Configuration {..} = do
8797 let report msg = fail ("*** configuration error: " ++ msg)
8898
8999 maintainedPackages = Set.unions (Map.elems packageMaintainers)
90− disabledPackages = Map.keysSet dontDistributePackages
100+ disabledPackages = dontDistributePackages `Set.union` brokenPackages
91101 disabledMaintainedPackages = maintainedPackages `Set.intersection` disabledPackages
92102 unless (Set.null disabledMaintainedPackages) $
93103 report ("disabled packages that have a maintainer: " ++ show disabledMaintainedPackages)