@@ -8,57 +8,16 @@
8 Portability : portable
8 Portability : portable
11−module Distribution.NixOS.Derivation.License
11+module Distribution.NixOS.Derivation.License ( License(..) ) where
17−import qualified Distribution.License as Cabal ( License(..) )
13+import Distribution.NixOS.PrettyPrinting
18−import Data.Version ( Version(..) )
19import Distribution.Text
14import Distribution.Text
20−import Text.PrettyPrint
32− | Unknown (Maybe String)
16+data License = Known String | Unknown (Maybe String)
33− deriving (Eq, Ord)
17+ deriving (Show, Eq, Ord)
35−instance Show License where
36− show GPL2 = "self.stdenv.lib.licenses.gpl2"
37− show GPL3 = "self.stdenv.lib.licenses.gpl3"
38− show LGPL21 = "self.stdenv.lib.licenses.lgpl21"
39− show LGPL3 = "self.stdenv.lib.licenses.gpl3"
40− show BSD3 = "self.stdenv.lib.licenses.bsd3"
41− show BSD4 = "self.stdenv.lib.licenses.bsd4"
42− show MIT = "self.stdenv.lib.licenses.mit"
43− show PublicDomain = "self.stdenv.lib.licenses.publicDomain"
44− show Proprietary = "self.stdenv.lib.licenses.proprietary"
45− show (Unknown lic) = show (maybe "unknown" id lic)
47instance Text License where
19instance Text License where
48− disp = text . show
20+ disp (Known x) = text x
21+ disp (Unknown x) = string (maybe "unknown" id x)
49 parse = error "parsing Distribution.NixOS.Derivation.License is not supported yet"
22 parse = error "parsing Distribution.NixOS.Derivation.License is not supported yet"
51−fromCabalLicense :: Cabal.License -> License
52−fromCabalLicense (Cabal.GPL Nothing) = Unknown (Just "GPL")
53−fromCabalLicense (Cabal.GPL (Just (Version [2] []))) = GPL2
54−fromCabalLicense (Cabal.GPL (Just (Version [3] []))) = GPL3
55−fromCabalLicense (Cabal.LGPL Nothing) = Unknown (Just "LGPL")
56−fromCabalLicense (Cabal.LGPL (Just (Version [2,1] []))) = LGPL21
57−fromCabalLicense (Cabal.LGPL (Just (Version [3] []))) = LGPL3
58−fromCabalLicense Cabal.BSD3 = BSD3
59−fromCabalLicense Cabal.BSD4 = BSD4
60−fromCabalLicense Cabal.MIT = MIT
61−fromCabalLicense Cabal.PublicDomain = PublicDomain
62−fromCabalLicense Cabal.AllRightsReserved = Proprietary
63−fromCabalLicense Cabal.OtherLicense = Unknown Nothing
64−fromCabalLicense l = error $ "Distribution.NixOS.Derivation.License.fromCabalLicense: unknown license " ++ show l