cabal2nix 2.14.2 → 2.14.3
raw patch · 6 files changed
+47/−41 lines, 6 filesdep ~aesondep ~containersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: aeson, containers
API changes (from Hackage documentation)
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: [brokenPackages] :: Configuration -> [Constraint]
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: [unsupportedPlatforms] :: Configuration -> Map PackageName (Set Platform)
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Types.VersionRange.VersionRange
- Distribution.Nixpkgs.Haskell.FromCabal.Configuration: Configuration :: CompilerInfo -> Set PackageIdentifier -> [Constraint] -> [Constraint] -> Map PackageName (Set Platform) -> Map Identifier (Set PackageName) -> Configuration
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: Configuration :: CompilerInfo -> Set PackageIdentifier -> [Constraint] -> [Constraint] -> Map Identifier (Set PackageName) -> Map PackageName (Set Platform) -> Set PackageName -> [Constraint] -> Configuration
- Distribution.Nixpkgs.Haskell.FromCabal.Configuration: [dontDistributePackages] :: Configuration -> Map PackageName (Set Platform)
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: [dontDistributePackages] :: Configuration -> Set PackageName
Files
- cabal2nix.cabal +4/−4
- hackage2nix/Main.hs +12/−3
- src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs +23/−30
- src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs +1/−0
- src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs +3/−4
- src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs +4/−0
cabal2nix.cabal view
@@ -1,5 +1,5 @@ name: cabal2nix-version: 2.14.2+version: 2.14.3 synopsis: Convert Cabal files into Nix build instructions. description: Convert Cabal files into Nix build instructions. Users of Nix can install the latest@@ -74,7 +74,7 @@ Александр Цамутали maintainer: Peter Simons <simons@cryp.to> stability: stable-tested-with: GHC == 8.6.3+tested-with: GHC == 8.6.4 category: Distribution, Nix homepage: https://github.com/nixos/cabal2nix#readme bug-reports: https://github.com/nixos/cabal2nix/issues@@ -109,10 +109,10 @@ hs-source-dirs: src build-depends: base > 4.11 , Cabal > 2.4- , aeson+ , aeson > 1 , ansi-wl-pprint , bytestring- , containers+ , containers >= 0.5.9 , deepseq >= 1.4 , directory , distribution-nixpkgs >= 1.2
hackage2nix/Main.hs view
@@ -77,6 +77,8 @@ . Map.delete "som" -- TODO: https://github.com/NixOS/cabal2nix/issues/164 . Map.delete "type" -- TODO: https://github.com/NixOS/cabal2nix/issues/163 . Map.delete "control-invariants" -- TODO: depends on "assert"+ . Map.delete "with" -- TODO: https://github.com/NixOS/cabal2nix/issues/164+ . Map.delete "telega" -- TODO: depends on "with" . over (at "hermes") (fmap (set (contains "1.3.4.3") False)) -- TODO: https://github.com/haskell/hackage-server/issues/436 hackage <- fixup <$> readHackage hackageRepository let@@ -132,9 +134,14 @@ (descr, cabalSHA256) <- readPackage hackageRepository pkgId meta <- readPackageMeta hackageRepository pkgId - let isInDefaultPackageSet :: Bool+ let isInDefaultPackageSet, isHydraEnabled, isBroken :: Bool isInDefaultPackageSet = (== Just v) (Map.lookup name generatedDefaultPackageSet)+ isHydraEnabled = isInDefaultPackageSet && not (isBroken || name `Set.member` dontDistributePackages config)+ isBroken = any (withinRange v) [ vr | Dependency pn vr <- brokenPackages config, pn == name ] + droppedPlatforms :: Set Platform+ droppedPlatforms = Map.findWithDefault mempty name (unsupportedPlatforms config)+ tarballSHA256 :: SHA256Hash tarballSHA256 = fromMaybe (error (display pkgId ++ ": meta data has no hash for the tarball")) (view (hashes . at "SHA256") meta)@@ -149,9 +156,11 @@ drv = fromGenericPackageDescription haskellResolver nixpkgsResolver targetPlatform (compilerInfo config) flagAssignment [] descr & src .~ urlDerivationSource ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") tarballSHA256 & editedCabalFile .~ cabalSHA256- & metaSection.hydraPlatforms %~ (`Set.difference` Map.findWithDefault Set.empty name (dontDistributePackages config))+ & metaSection.platforms %~ (`Set.difference` Map.findWithDefault Set.empty name (unsupportedPlatforms config))+ & metaSection.hydraPlatforms %~ (if Set.null droppedPlatforms then id else (`Set.difference` droppedPlatforms))+ & metaSection.hydraPlatforms %~ (if isHydraEnabled then id else const Set.empty)+ & metaSection.broken ||~ isBroken & metaSection.maintainers .~ Map.findWithDefault Set.empty name globalPackageMaintainers- & metaSection.hydraPlatforms %~ (if isInDefaultPackageSet then id else const Set.empty) & metaSection.homepage .~ "" overrides :: Doc
src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs view
@@ -1,14 +1,16 @@ {-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveGeneric #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -module Distribution.Nixpkgs.Haskell.FromCabal.Configuration ( Configuration(..), readConfiguration, assertConsistency ) where+module Distribution.Nixpkgs.Haskell.FromCabal.Configuration+ ( Configuration(..), readConfiguration, assertConsistency+ )+ where -import Control.Exception ( throwIO ) import Control.DeepSeq+import Control.Exception ( throwIO ) import Control.Lens import Control.Monad import Data.Aeson@@ -40,14 +42,22 @@ -- role during dependency resolution. , extraPackages :: [Constraint] - -- |We know that these packages won't build, so we give them an empty- -- meta.hydraPlatforms attribute to avoid cluttering our Hydra output with- -- lots of failure messages.- , dontDistributePackages :: Map PackageName (Set Platform)- -- |This information is used by the @hackage2nix@ utility to determine the -- 'maintainers' for a given Haskell package. , packageMaintainers :: Map Identifier (Set PackageName)++ -- |These packages (by design) don't support certain platforms.+ , unsupportedPlatforms :: Map PackageName (Set Platform)++ -- |These packages cannot be distributed by Hydra, i.e. because they have an+ -- unfree license or depend on other tools that cannot be distributed for+ -- some reason.+ , dontDistributePackages :: Set PackageName++ -- |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 :: [Constraint] } deriving (Show, Generic) @@ -59,50 +69,33 @@ <*> o .:? "core-packages" .!= mempty <*> o .:? "default-package-overrides" .!= mempty <*> o .:? "extra-packages" .!= mempty- <*> o .:? "dont-distribute-packages" .!= mempty <*> o .:? "package-maintainers" .!= mempty+ <*> o .:? "unsupported-platforms" .!= mempty+ <*> o .:? "dont-distribute-packages" .!= mempty+ <*> o .:? "broken-packages" .!= mempty parseJSON _ = error "invalid Configuration" instance FromJSON Identifier where parseJSON (String s) = pure (review ident (T.unpack s)) parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier") -#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--#else--instance (Ord k, FromJSON k, FromJSON v) => FromJSON (Map k v) where- parseJSON = fmap (Map.mapKeys parseKey) . parseJSON--#endif- 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 = Map.keysSet dontDistributePackages+ 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)
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs view
@@ -105,6 +105,7 @@ libNixName "m" = [] -- in stdenv libNixName "magic" = return "file" libNixName "MagickWand" = return "imagemagick"+libNixName "mnl" = return "libmnl" libNixName "mpi" = return "openmpi" libNixName "ncursesw" = return "ncurses" libNixName "netsnmp" = return "net_snmp"
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs view
@@ -229,13 +229,12 @@ where gitAnnexOverrides = unlines [ "preConfigure = \"export HOME=$TEMPDIR; patchShebangs .\";"- , "installPhase = \"make PREFIX=$out BUILDER=: install\";"- , "checkPhase = ''"+ , "postBuild = ''" , " ln -sf dist/build/git-annex/git-annex git-annex" , " ln -sf git-annex git-annex-shell"- , " export PATH+=\":$PWD\""- , " git-annex test" , "'';"+ , "installPhase = \"make PREFIX=$out BUILDER=: install install-completions\";"+ , "checkPhase = ''PATH+=\":$PWD\" git-annex test'';" , "enableSharedExecutables = false;" ] buildInputs = pkgs ["git","rsync","gnupg","curl","wget","lsof","openssh","which","bup","perl"]
src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs view
@@ -49,6 +49,10 @@ 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")