@@ -1,4 +1,4 @@
1−{-# LANGUAGE DeriveGeneric #-}
1+{-# LANGUAGE DeriveGeneric, RecordWildCards #-}
22{- |
33 Module : Distribution.NixOS.Derivation.Meta
44 License : BSD3
@@ -22,14 +22,16 @@ import Control.DeepSeq.Generics
2222import Distribution.NixOS.Derivation.License
2323import Distribution.NixOS.Util.PrettyPrinting
2424import GHC.Generics ( Generic )
25+import Data.Set ( Set )
26+import qualified Data.Set as Set
2527
2628-- | A representation of the @meta@ section used in Nix expressions.
2729--
2830-- >>> :{
2931-- print (pPrint (Meta "http://example.org" "an example package" (Unknown Nothing)
30−-- ["stdenv.lib.platforms.unix"]
31−-- ["stdenv.lib.platforms.none"]
32−-- ["joe","jane"]
32+-- (Set.singleton "stdenv.lib.platforms.unix")
33+-- (Set.singleton "stdenv.lib.platforms.none")
34+-- (Set.fromList ["joe","jane"])
3335-- True))
3436-- :}
3537-- homepage = "http://example.org";
@@ -37,20 +39,20 @@ import GHC.Generics ( Generic )
3739-- license = "unknown";
3840-- platforms = stdenv.lib.platforms.unix;
3941-- hydraPlatforms = stdenv.lib.platforms.none;
40−-- maintainers = with stdenv.lib.maintainers; [ joe jane ];
42+-- maintainers = with stdenv.lib.maintainers; [ jane joe ];
4143-- broken = true;
4244--
4345-- Note that the "Text" instance definition provides pretty-printing,
4446-- but no parsing as of now!
4547
4648data Meta = Meta
47− { homepage :: String -- ^ URL of the package homepage
48− , description :: String -- ^ short description of the package
49− , license :: License -- ^ licensing terms
50− , platforms :: [String] -- ^ list of supported platforms (from @pkgs\/lib\/platforms.nix@)
51− , hydraPlatforms :: [String] -- ^ list of platforms built by Hydra (from @pkgs\/lib\/platforms.nix@)
52− , maintainers :: [String] -- ^ list of maintainers from @pkgs\/lib\/maintainers.nix@
53− , broken :: Bool -- ^ set to @true@ if the build is known to fail
49+ { homepage :: String -- ^ URL of the package homepage
50+ , description :: String -- ^ short description of the package
51+ , license :: License -- ^ licensing terms
52+ , platforms :: Set String -- ^ list of supported platforms (from @pkgs\/lib\/platforms.nix@)
53+ , hydraPlatforms :: Set String -- ^ list of platforms built by Hydra (from @pkgs\/lib\/platforms.nix@)
54+ , maintainers :: Set String -- ^ list of maintainers from @pkgs\/lib\/maintainers.nix@
55+ , broken :: Bool -- ^ set to @true@ if the build is known to fail
5456 }
5557 deriving (Show, Eq, Ord, Generic)
5658
@@ -60,16 +62,16 @@ instance Pretty Meta where
6062instance NFData Meta where rnf = genericRnf
6163
6264renderMeta :: Meta -> Doc
63−renderMeta meta = vcat
64− [ onlyIf (not (null (homepage meta))) $ attr "homepage" $ string (homepage meta)
65− , onlyIf (not (null (description meta))) $ attr "description" $ string (description meta)
66− , attr "license" $ pPrint (license meta)
67− , onlyIf (not (null (platforms meta)) && platforms meta /= ["ghc.meta.platforms"]) $ sep
68− [ text "platforms" <+> equals, renderPlatformList (platforms meta) ]
69− , onlyIf (not (null (hydraPlatforms meta))) $ sep
70− [ text "hydraPlatforms" <+> equals, renderPlatformList (hydraPlatforms meta) ]
71− , listattr "maintainers" (text "with stdenv.lib.maintainers;") (maintainers meta)
72− , boolattr "broken" (broken meta) (broken meta)
65+renderMeta (Meta {..}) = vcat
66+ [ onlyIf (not (null homepage)) $ attr "homepage" $ string homepage
67+ , onlyIf (not (null description)) $ attr "description" $ string description
68+ , attr "license" $ pPrint license
69+ , onlyIf (not (Set.null platforms) && platforms /= Set.singleton "ghc.meta.platforms") $ sep
70+ [ text "platforms" <+> equals, renderPlatformList (Set.toAscList platforms) ]
71+ , onlyIf (not (Set.null hydraPlatforms)) $ sep
72+ [ text "hydraPlatforms" <+> equals, renderPlatformList (Set.toAscList hydraPlatforms) ]
73+ , listattr "maintainers" (text "with stdenv.lib.maintainers;") (Set.toAscList maintainers)
74+ , boolattr "broken" broken broken
7375 ]
7476
7577renderPlatformList :: [String] -> Doc