summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2023-02-03 18:10:41 +0100
committertv <tv@krebsco.de>2023-02-05 01:40:20 +0100
commit6372ea4f4f9fb8ccfe5ed9c2571b07895910498a (patch)
treeca412c87b9661a96cc73b218d9a809eb5a8555eb /lib
parent880eb5310d3ddf8da4907aadb7ecdf45f2f892d3 (diff)
lib.types.boundedInt: init
Diffstat (limited to 'lib')
-rw-r--r--lib/types.nix6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/types.nix b/lib/types.nix
index 32b4541..cda3381 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -287,6 +287,12 @@ rec {
};
});
+ boundedInt = min: max: mkOptionType {
+ name = "bounded integer";
+ check = x: isInt x && min <= x && x <= max;
+ merge = mergeOneOption;
+ };
+
positive = mkOptionType {
name = "positive integer";
check = x: isInt x && x > 0;