From 6372ea4f4f9fb8ccfe5ed9c2571b07895910498a Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 3 Feb 2023 18:10:41 +0100 Subject: lib.types.boundedInt: init --- lib/types.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/types.nix') 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; -- cgit v1.2.3 From ffb24500ef54ff15b87b497c4a9ae71e7c6f4ec4 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 3 Feb 2023 18:10:50 +0100 Subject: lib.types.lowerBoundedInt: init --- lib/types.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/types.nix') diff --git a/lib/types.nix b/lib/types.nix index cda3381..f7c4916 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; }; -- cgit v1.2.3 From 889a27da7e532cfff95c684cc137b009545288c7 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 5 Feb 2023 00:41:47 +0100 Subject: lib.types.svg.color-keyword: init --- lib/types.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/types.nix') diff --git a/lib/types.nix b/lib/types.nix index f7c4916..4bb8c17 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -3,8 +3,8 @@ let inherit (lib) all any attrNames concatMapStringsSep concatStringsSep const filter flip - genid_uint31 hasSuffix head isInt isString length mergeOneOption mkOption - mkOptionType optional optionalAttrs optionals range splitString + genid_uint31 hasSuffix head importJSON isInt isString length mergeOneOption + mkOption mkOptionType optional optionalAttrs optionals range splitString stringLength substring test testString typeOf; inherit (lib.types) attrsOf bool either enum int lines listOf nullOr path str submodule; @@ -613,6 +613,19 @@ rec { merge = mergeOneOption; }; + # SVG 1.1, 4.4 Recognized color keyword names + # + # svg-colors.json has been generated with: + # curl -sS https://www.w3.org/TR/SVG11/types.html#ColorKeywords | + # fq -d html '[ + # grep_by(.["@class"]=="color-keywords") | + # grep_by(.["@class"]=="prop-value"and.["#text"]!="").["#text"] + # ] | sort' + # + svg.color-keyword = enum (importJSON ./svg-colors.json) // { + name = "SVG 1.1 recognized color keyword"; + }; + systemd.unit-name = mkOptionType { name = "systemd unit name"; check = x: -- cgit v1.2.3 From 1d1ab286f4fda352d3e598a4b2addc3992c02e85 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 4 Feb 2023 21:52:14 +0100 Subject: flameshot-once: reinit with flameshot 12.1.0-pre --- lib/types.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/types.nix') diff --git a/lib/types.nix b/lib/types.nix index 4bb8c17..5f01ccb 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -7,7 +7,7 @@ let mkOption mkOptionType optional optionalAttrs optionals range splitString stringLength substring test testString typeOf; inherit (lib.types) - attrsOf bool either enum int lines listOf nullOr path str submodule; + addCheck attrsOf bool either enum int lines listOf nullOr path str submodule; in rec { @@ -595,6 +595,9 @@ rec { }; }; + flameshot.color = + either (addCheck str (test "#[0-9A-Fa-f]{6}")) svg.color-keyword; + file-mode = mkOptionType { name = "file mode"; check = test "[0-7]{4}"; -- cgit v1.2.3