1{-# LANGUAGE DeriveGeneric #-}
3 Known licenses in Nix expressions are represented using the
4 attributes defined in @pkgs\/lib\/licenses.nix@, and unknown licenses
5 are represented as a literal string.
8module Distribution.Nixpkgs.License ( License(..) ) where
10import Control.DeepSeq.Generics
12import Distribution.Nixpkgs.Util.PrettyPrinting
13import GHC.Generics ( Generic )
15-- | The representation for licenses used in Nix derivations. Known
16-- licenses are Nix expressions -- such as @stdenv.lib.licenses.bsd3@
17-- --, so their exact \"name\" is not generally known, because the path
18-- to @stdenv@ depends on the context defined in the expression. In
19-- Cabal expressions, for example, the BSD3 license would have to be
20-- referred to as @self.stdenv.lib.licenses.bsd3@. Other expressions,
21-- however, use different paths to the @licenses@ record. Because of tat
22-- situation, the library cannot provide an abstract data type that
23-- encompasses all known licenses. Instead, the @License@ type just
24-- distinguishes references to known and unknown licenses. The
25-- difference between the two is in the way they are pretty-printed:
27-- > > putStrLn (display (Known "stdenv.lib.license.gpl2"))
28-- > stdenv.lib.license.gpl2
30-- > > putStrLn (display (Unknown (Just "GPL")))
33-- > > putStrLn (display (Unknown Nothing))
36-- Note that the "Text" instance definition provides pretty-printing,
37-- but no parsing as of now!
39data License = Known String
40 | Unknown (Maybe String)
41 deriving (Show, Eq, Ord, Generic)
43instance Pretty License where
44 pPrint (Known x) = text x
45 pPrint (Unknown x) = string (fromMaybe "unknown" x)
47instance NFData License where rnf = genericRnf
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list