git.iko.soy/typeable/cabal2nix
on master help sign in
hackage2nix: add known package maintainers to the configuration
dadc3b0Peter Simons
src/Distribution/Nixpkgs/Haskell/BuildInfo.hs+4−4
@@ -38,8 +38,8 @@ instance NFData BuildInfo where rnf = genericRnf
38
38
39pPrintBuildInfo :: String -> BuildInfo -> Doc
39pPrintBuildInfo :: String -> BuildInfo -> Doc
40pPrintBuildInfo prefix bi = vcat
40pPrintBuildInfo prefix bi = vcat
41− [ setattr (prefix++"HaskellDepends") (setOf (haskell.folded.localName.ident) bi)
41+ [ setattr (prefix++"HaskellDepends") empty (setOf (haskell.folded.localName.ident) bi)
42− , setattr (prefix++"SystemDepends") (setOf (system.folded.localName.ident) bi)
42+ , setattr (prefix++"SystemDepends") empty (setOf (system.folded.localName.ident) bi)
43− , setattr (prefix++"PkgconfigDepends") (setOf (pkgconfig.folded.localName.ident) bi)
43+ , setattr (prefix++"PkgconfigDepends") empty (setOf (pkgconfig.folded.localName.ident) bi)
44− , setattr (prefix++"ToolDepends") (setOf (tool.folded.localName.ident) bi)
44+ , setattr (prefix++"ToolDepends") empty (setOf (tool.folded.localName.ident) bi)
45 ]
45 ]
src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+7
@@ -5,6 +5,7 @@ module Distribution.Nixpkgs.Haskell.FromCabal.Configuration
5 , module Distribution.Compiler
5 , module Distribution.Compiler
6 , module Distribution.Nixpkgs.Haskell.Constraint
6 , module Distribution.Nixpkgs.Haskell.Constraint
7 , module Distribution.Version
7 , module Distribution.Version
8+ , module Language.Nix.Identifier
8 ) where
9 ) where
9
10
10import Data.Set
11import Data.Set
@@ -13,6 +14,8 @@ import Distribution.System
13import Distribution.Compiler
14import Distribution.Compiler
14import Distribution.Nixpkgs.Haskell.Constraint
15import Distribution.Nixpkgs.Haskell.Constraint
15import Distribution.Version
16import Distribution.Version
17+import Data.Map
18+import Language.Nix.Identifier
16
19
17data Configuration = Configuration
20data Configuration = Configuration
18 {
21 {
@@ -42,5 +45,9 @@ data Configuration = Configuration
42 -- meta.hydraPlatforms attribute to avoid cluttering our Hydra output with
45 -- meta.hydraPlatforms attribute to avoid cluttering our Hydra output with
43 -- lots of failure messages.
46 -- lots of failure messages.
44 , dontDistributePackages :: Set PackageName
47 , dontDistributePackages :: Set PackageName
48+
49+ -- |This information is used by the @hackage2nix@ utility to determine the
50+ -- 'maintainers' for a given Haskell package.
51+ , packageMaintainers :: Map PackageName (Set Identifier)
45 }
52 }
46 deriving (Show)
53 deriving (Show)
src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration/GHC7102.hs+7−2
@@ -1,8 +1,11 @@
1−module Distribution.Nixpkgs.Haskell.FromCabal.Configuration.GHC7102 ( Configuration(..), ghc7102 ) where
1+module Distribution.Nixpkgs.Haskell.FromCabal.Configuration.GHC7102
2+ ( Configuration(..), ghc7102
3+ ) where
2
4
3import Data.Maybe ( fromMaybe )
5import Data.Maybe ( fromMaybe )
4import qualified Data.Set as Set
6import qualified Data.Set as Set
5import Distribution.Nixpkgs.Haskell.FromCabal.Configuration
7import Distribution.Nixpkgs.Haskell.FromCabal.Configuration
8+import Distribution.Nixpkgs.Haskell.FromCabal.Configuration.Maintainers
6import Distribution.Text ( simpleParse )
9import Distribution.Text ( simpleParse )
7
10
8ghc7102 :: Configuration
11ghc7102 :: Configuration
@@ -11,6 +14,8 @@ ghc7102 = Configuration
11
14
12 , compilerInfo = unknownCompilerInfo (CompilerId GHC (Version [7,10,2] [])) NoAbiTag
15 , compilerInfo = unknownCompilerInfo (CompilerId GHC (Version [7,10,2] [])) NoAbiTag
13
16
17+ , packageMaintainers = globalPackageMaintainers
18+
14 , defaultPackageOverrides = map (\s -> fromMaybe (error (show s ++ " is not a valid override selector")) (simpleParse s))
19 , defaultPackageOverrides = map (\s -> fromMaybe (error (show s ++ " is not a valid override selector")) (simpleParse s))
15 [ "HUnit < 1.3.0.0" -- newer versions break test-framework-hunit-0.3.0.1
20 [ "HUnit < 1.3.0.0" -- newer versions break test-framework-hunit-0.3.0.1
16 ]
21 ]
@@ -3676,4 +3681,4 @@ ghc7102 = Configuration
3676 , "wai-middleware-metrics"
3681 , "wai-middleware-metrics"
3677 ]
3682 ]
3678
3683
3679−}
3684+ }
src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration/Maintainers.hsnew file+21
@@ -0,0 +1,21 @@
1+module Distribution.Nixpkgs.Haskell.FromCabal.Configuration.Maintainers ( globalPackageMaintainers ) where
2+
3+import Data.Map as Map
4+import Data.Set as Set
5+import Distribution.Nixpkgs.Haskell.FromCabal.Configuration
6+import Internal.Lens
7+
8+globalPackageMaintainers :: Map PackageName (Set Identifier)
9+globalPackageMaintainers = Map.unionsWith Set.union [ Map.singleton p (Set.singleton m) | (m,ps) <- maintainedPackages, p <- ps ]
10+
11+maintainedPackages :: [(Identifier, [PackageName])]
12+maintainedPackages =
13+ [ "simons" |->
14+ [ "archlinux", "cabal2arch", "cabal2nix", "funcmp", "hackage-db", "halipeto"
15+ , "hledger-interest", "hopenssl", "hsdns", "hsemail", "hsyslog", "jailbreak-cabal"
16+ , "language-nix", "streamproc"
17+ ]
18+ ]
19+
20+(|->) :: String -> [String] -> (Identifier,[PackageName])
21+(|->) m ps = (create ident m, Prelude.map PackageName ps)
src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs−15
@@ -12,7 +12,6 @@ import Distribution.Package
12import Distribution.PackageDescription ( FlagAssignment, FlagName(..) )
12import Distribution.PackageDescription ( FlagAssignment, FlagName(..) )
13import Distribution.Simple.Utils ( lowercase )
13import Distribution.Simple.Utils ( lowercase )
14import Internal.Lens
14import Internal.Lens
15−import Internal.Regex ( regsubmatch )
16import Language.Nix hiding ( quote )
15import Language.Nix hiding ( quote )
17
16
18normalize :: Derivation -> Derivation
17normalize :: Derivation -> Derivation
@@ -41,7 +40,6 @@ normalizeBuildInfo (PackageName pname) bi = bi
41
40
42normalizeMeta :: Meta -> Meta
41normalizeMeta :: Meta -> Meta
43normalizeMeta = over description normalizeSynopsis
42normalizeMeta = over description normalizeSynopsis
44− . over maintainers normalizeMaintainers
45 . over platforms normalizePlatforms
43 . over platforms normalizePlatforms
46
44
47normalizeSynopsis :: String -> String
45normalizeSynopsis :: String -> String
@@ -68,19 +66,6 @@ normalizeSet = Set.filter (not . null)
68-- normalizeNixBuildTools :: Set Identifier -> Set Identifier
66-- normalizeNixBuildTools :: Set Identifier -> Set Identifier
69-- normalizeNixBuildTools = Set.fromList . concatMap buildToolNixName . Set.toList
67-- normalizeNixBuildTools = Set.fromList . concatMap buildToolNixName . Set.toList
70
68
71−-- |Strip any kind of path prefix from maintainer names, filter duplicates, and
72−-- sort the resulting list alphabetically.
73−--
74−-- >>> normalizeMaintainers $ Set.fromList ["self.stdenv.lib.maintainers.foobar", "foobar"]
75−-- fromList ["foobar"]
76−--
77−-- >>> normalizeMaintainers $ Set.fromList ["any.prefix.is.recognized.yo", "abc.def"]
78−-- fromList ["def","yo"]
79−
80−normalizeMaintainers :: Set String -> Set String
81−normalizeMaintainers = normalizeSet . Set.map
82− (\m -> (m `regsubmatch` "^([^.].*\\.)?([^.]+)$") !! 1)
83−
84normalizePlatforms :: Set String -> Set String
69normalizePlatforms :: Set String -> Set String
85normalizePlatforms = normalizeSet . Set.map
70normalizePlatforms = normalizeSet . Set.map
86 (\p -> if '.' `elem` p then p else "stdenv.lib.platforms." ++ p)
71 (\p -> if '.' `elem` p then p else "stdenv.lib.platforms." ++ p)
src/Distribution/Nixpkgs/Meta.hs+13−12
@@ -13,12 +13,13 @@ module Distribution.Nixpkgs.Meta
13
13
14
14
15import Control.DeepSeq.Generics
15import Control.DeepSeq.Generics
16−import Internal.Lens
17−import Distribution.Nixpkgs.License
18−import Internal.PrettyPrinting
19−import GHC.Generics ( Generic )
20import Data.Set ( Set )
16import Data.Set ( Set )
21import qualified Data.Set as Set
17import qualified Data.Set as Set
18+import Distribution.Nixpkgs.License
19+import GHC.Generics ( Generic )
20+import Internal.Lens
21+import Internal.PrettyPrinting
22+import Language.Nix.Identifier
22
23
23-- | A representation of the @meta@ section used in Nix expressions.
24-- | A representation of the @meta@ section used in Nix expressions.
24--
25--
@@ -41,13 +42,13 @@ import qualified Data.Set as Set
41-- but no parsing as of now!
42-- but no parsing as of now!
42
43
43data Meta = Meta
44data Meta = Meta
44− { _homepage :: String -- ^ URL of the package homepage
45+ { _homepage :: String -- ^ URL of the package homepage
45− , _description :: String -- ^ short description of the package
46+ , _description :: String -- ^ short description of the package
46− , _license :: License -- ^ licensing terms
47+ , _license :: License -- ^ licensing terms
47− , _platforms :: Set String -- ^ list of supported platforms (from @pkgs\/lib\/platforms.nix@)
48+ , _platforms :: Set String -- ^ list of supported platforms (from @pkgs\/lib\/platforms.nix@)
48− , _hydraPlatforms :: Set String -- ^ list of platforms built by Hydra (from @pkgs\/lib\/platforms.nix@)
49+ , _hydraPlatforms :: Set String -- ^ list of platforms built by Hydra (from @pkgs\/lib\/platforms.nix@)
49− , _maintainers :: Set String -- ^ list of maintainers from @pkgs\/lib\/maintainers.nix@
50+ , _maintainers :: Set Identifier -- ^ list of maintainers from @pkgs\/lib\/maintainers.nix@
50− , _broken :: Bool -- ^ set to @true@ if the build is known to fail
51+ , _broken :: Bool -- ^ set to @true@ if the build is known to fail
51 }
52 }
52 deriving (Show, Eq, Ord, Generic)
53 deriving (Show, Eq, Ord, Generic)
53
54
@@ -64,7 +65,7 @@ instance Pretty Meta where
64 [ text "platforms" <+> equals, renderPlatformList (Set.toAscList _platforms) ]
65 [ text "platforms" <+> equals, renderPlatformList (Set.toAscList _platforms) ]
65 , onlyIf (not (Set.null _hydraPlatforms)) $ sep
66 , onlyIf (not (Set.null _hydraPlatforms)) $ sep
66 [ text "hydraPlatforms" <+> equals, renderPlatformList (Set.toAscList _hydraPlatforms) ]
67 [ text "hydraPlatforms" <+> equals, renderPlatformList (Set.toAscList _hydraPlatforms) ]
67− , listattr "maintainers" (text "with stdenv.lib.maintainers;") (Set.toAscList _maintainers)
68+ , setattr "maintainers" (text "with stdenv.lib.maintainers;") (Set.map (view ident) _maintainers)
68 , boolattr "broken" _broken _broken
69 , boolattr "broken" _broken _broken
69 ]
70 ]
70
71
src/Internal/PrettyPrinting.hs+2−2
@@ -38,8 +38,8 @@ listattr n prefix vs = onlyIf (not (null vs)) $
38 rbrack <> semi
38 rbrack <> semi
39 ]
39 ]
40
40
41−setattr :: String -> Set String -> Doc
41+setattr :: String -> Doc -> Set String -> Doc
42−setattr name set = listattr name empty (toAscList set)
42+setattr name prefix set = listattr name prefix (toAscList set)
43
43
44toAscList :: Set String -> [String]
44toAscList :: Set String -> [String]
45toAscList = sortBy (compare `on` map toLower) . Set.toList
45toAscList = sortBy (compare `on` map toLower) . Set.toList
src/cabal2nix.hs+1−1
@@ -107,7 +107,7 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do
107 & hyperlinkSource .~ optHyperlinkSource
107 & hyperlinkSource .~ optHyperlinkSource
108 & enableLibraryProfiling .~ (fromMaybe False optEnableProfiling || optEnableLibraryProfiling)
108 & enableLibraryProfiling .~ (fromMaybe False optEnableProfiling || optEnableLibraryProfiling)
109 & enableExecutableProfiling .~ (fromMaybe False optEnableProfiling || optEnableExecutableProfiling)
109 & enableExecutableProfiling .~ (fromMaybe False optEnableProfiling || optEnableExecutableProfiling)
110− & metaSection.maintainers .~ Set.fromList optMaintainer
110+ & metaSection.maintainers .~ Set.fromList (map (create ident) optMaintainer)
111 & metaSection.platforms .~ Set.fromList optPlatform
111 & metaSection.platforms .~ Set.fromList optPlatform
112 & doCheck &&~ optDoCheck
112 & doCheck &&~ optDoCheck
113 & extraFunctionArgs . contains "stdenv" .~ True
113 & extraFunctionArgs . contains "stdenv" .~ True
src/hackage2nix.hs+4−1
@@ -163,9 +163,12 @@ generatePackageSet config hackage nixpkgs = do
163 srcSpec <- liftIO $ sourceFromHackage (Certain sha256) (name ++ "-" ++ display pkgversion)
163 srcSpec <- liftIO $ sourceFromHackage (Certain sha256) (name ++ "-" ++ display pkgversion)
164
164
165 let drv = drv' & src .~ srcSpec
165 let drv = drv' & src .~ srcSpec
166− & metaSection.hydraPlatforms .~ (if PackageName name `Set.member` brokenPackages config
166+ & metaSection.hydraPlatforms .~ (if PackageName name `Set.member` dontDistributePackages config
167 then Set.singleton "stdenv.lib.platforms.none"
167 then Set.singleton "stdenv.lib.platforms.none"
168 else drv'^.metaSection.hydraPlatforms)
168 else drv'^.metaSection.hydraPlatforms)
169+ & metaSection.maintainers .~ fromMaybe Set.empty (Map.lookup (PackageName name) (packageMaintainers config))
170+
171+
169
172
170 isFromHackage :: Binding -> Bool
173 isFromHackage :: Binding -> Bool
171 isFromHackage b = case view (reference . path) b of
174 isFromHackage b = case view (reference . path) b of