2024-09-29 23:22:26 +02:00
|
|
|
{lib}: let
|
2024-10-04 23:01:41 +02:00
|
|
|
inherit (lib.strings) isString;
|
2024-09-29 23:22:26 +02:00
|
|
|
inherit (lib.types) mkOptionType;
|
2024-10-04 23:01:41 +02:00
|
|
|
inherit (builtins) match;
|
2024-09-29 23:22:26 +02:00
|
|
|
# This was almost entirely taken from raf himself.
|
|
|
|
in {
|
|
|
|
hexColorType = mkOptionType {
|
|
|
|
name = "hex-color";
|
|
|
|
descriptionClass = "noun";
|
|
|
|
description = "RGB color in hex format";
|
2024-10-04 23:01:41 +02:00
|
|
|
# Check to determine wether the provided color is base16-valid
|
|
|
|
check = x: isString x && (match "#[0-9a-fA-F]{6}" x) != null;
|
2024-09-29 23:22:26 +02:00
|
|
|
};
|
|
|
|
}
|