summaryrefslogtreecommitdiffstats
path: root/lib/licenses/operators.nix
blob: db7cc25d37c6a7c681001ee84dd4dbb678625b91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
  /**
    This should be used when there is a choice of which license expression to use.
    This is a disjunctive binary "OR" operator.

    # Example

    ```nix
    OR [ lib.licenses.mit lib.licenses.asl20 ]
    => { licenseType = "compound"; operator = "OR"; licenses = [ lib.licenses.mit lib.licenses.asl20 ] };
    ```

    # Type

    ```
    OR :: List -> AttrSet
    ```

    # Arguments

    - [licenses] Possible licenses to choose from
  */
  OR = licenses: {
    licenseType = "compound";
    operator = "OR";
    inherit licenses;
  };

  /**
     Create a compound licenses where the user needs to follow both licenses,
     eqivialent of spdx `and` modifier.

    # Example

    ```nix
    AND [ lib.licenses.mit lib.licenses.asl20 ]
    => { licenseType = "compound"; operator = "AND"; licenses = [ lib.licenses.mit lib.licenses.asl20 ] };
    ```

    # Type

    ```
    AND :: List -> AttrSet
    ```

    # Arguments

    - [licenses] Licenses required to use
  */
  AND = licenses: {
    licenseType = "compound";
    operator = "AND";
    inherit licenses;
  };

  /**
     Create a licenses exception where a license has a license exception,
     eqivialent of spdx `with` modifier.

    # Example

    ```nix
    WITH lib.licenses.lgpl21Only lib.licenses.ocamlLgplLinkingException
    => { licenseType = "exception"; operator = "WITH"; license = lib.licenses.lgpl21Only; exception = lib.licenses.ocamlLgplLinkingException; };
    ```

    # Type

    ```
    WITH :: AttrSet -> AttrSet -> AttrSet
    ```

    # Arguments

    - [license] License to which the exception applies
    - [exception] Exception to apply
  */
  WITH = license: exception: {
    licenseType = "exception";
    operator = "WITH";
    inherit license exception;
  };

  /**
     Create a licenses which can be upgraded to any later version of itself,
     eqivialent of spdx `+` modifier

    # Example

    ```nix
    PLUS lib.licenses.eupl11
    => { licenseType = "plus"; operator = "+"; license = lib.licenses.eupl11; };
    ```

    # Type

    ```
    PLUS :: AttrSet -> AttrSet
    ```

    # Arguments

    - [license] License to wich apply an exception
  */
  PLUS = license: {
    licenseType = "plus";
    operator = "+";
    inherit license;
  };
}