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