|
25 | 25 | ; |
26 | 26 |
|
27 | 27 | # keep-sorted start case=no block=yes newline_separated=yes |
28 | | - attrs = delib.types.attrsOf delib.types.anything; |
| 28 | + attrs = delib.types.attrsOf delib.types.unspecified; |
29 | 29 |
|
30 | 30 | attrsLegacy = lib.types.attrs; |
31 | 31 |
|
32 | | - function = delib.types.functionTo delib.types.anything; |
| 32 | + function = delib.types.functionTo delib.types.unspecified; |
33 | 33 |
|
34 | 34 | # FIX https://github.com/NixOS/nixpkgs/issues/438933 |
35 | 35 | functionTo = |
|
71 | 71 | nestedTypes.elemType = elemType; |
72 | 72 | }; |
73 | 73 |
|
74 | | - intBetween = lib.types.ints.between; |
| 74 | + intBetween = |
| 75 | + lowest: highest: |
| 76 | + assert lib.assertMsg (lowest <= highest) "intBetween: lowest must be smaller than highest"; |
| 77 | + lib.types.addCheck delib.types.int (x: x >= lowest && x <= highest) |
| 78 | + // { |
| 79 | + name = "intBetween"; |
| 80 | + description = "integer between ${toString lowest} and ${toString highest} (both inclusive)"; |
| 81 | + }; |
75 | 82 |
|
76 | | - lazyAttrs = delib.types.lazyAttrsOf delib.types.anything; |
| 83 | + lazyAttrs = delib.types.lazyAttrsOf delib.types.unspecified; |
77 | 84 |
|
78 | | - list = delib.types.listOf delib.types.anything; |
| 85 | + list = delib.types.listOf delib.types.unspecified; |
79 | 86 |
|
80 | 87 | null = lib.mkOptionType { |
81 | 88 | name = "null"; |
|
87 | 94 | value = null; |
88 | 95 | }; |
89 | 96 | }; |
| 97 | + |
| 98 | + steppedInt = |
| 99 | + step: |
| 100 | + assert lib.assertMsg (builtins.isInt step) "steppedInt: step must be an integer"; |
| 101 | + lib.types.addCheck delib.types.int (x: x == x / step * step) |
| 102 | + // { |
| 103 | + name = "steppedInt"; |
| 104 | + description = "integer that is a multiple of ${step}"; |
| 105 | + }; |
| 106 | + |
| 107 | + steppedIntBetween = |
| 108 | + lowest: highest: step: |
| 109 | + assert lib.assertMsg (builtins.isInt step) "steppedInt: step must be an integer"; |
| 110 | + assert lib.assertMsg (lowest <= highest) "intBetween: lowest must be smaller than highest"; |
| 111 | + lib.types.addCheck delib.types.int (x: x >= lowest && x <= highest && x == x / step * step) |
| 112 | + // { |
| 113 | + name = "steppedIntBetween"; |
| 114 | + description = "integer between ${toString lowest} and ${toString highest} (inclusive) that is a multiple of ${step}"; |
| 115 | + }; |
90 | 116 | # keep-sorted end |
91 | 117 | } |
0 commit comments