summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2023-02-03 18:10:50 +0100
committertv <tv@krebsco.de>2023-02-05 01:40:20 +0100
commit3b04273d5cf816897ba6f0b1879bea259726703b (patch)
treeeff4937962a14a30fb0937144fb48a22ec06f0de /lib
parent7b8f46c398b459bdbb9650465d5912100dd5f3fe (diff)
lib.types.lowerBoundedInt: init
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;
};