summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/types.nix10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/types.nix b/lib/types.nix
index cda338130..f7c491645 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -293,15 +293,21 @@ rec {
merge = mergeOneOption;
};
+ lowerBoundedInt = min: mkOptionType {
+ name = "lower bounded integer";
+ check = x: isInt x && min <= x;
+ merge = mergeOneOption;
+ };
+
positive = mkOptionType {
+ inherit (lowerBoundedInt 1) check;
name = "positive integer";
- check = x: isInt x && x > 0;
merge = mergeOneOption;
};
uint = mkOptionType {
+ inherit (lowerBoundedInt 0) check;
name = "unsigned integer";
- check = x: isInt x && x >= 0;
merge = mergeOneOption;
};