summaryrefslogtreecommitdiffstats
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
commit7b8f46c398b459bdbb9650465d5912100dd5f3fe (patch)
tree57dc3746b89fa761e4e09d5b25f990b85447e57d
parent90b46307b5d71b36f28eed78dfcdd2b2e6b57972 (diff)
lib.types.boundedInt: init
-rw-r--r--lib/types.nix6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/types.nix b/lib/types.nix
index 32b4541ae..cda338130 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;