From c1fe4b8508c2cf8e24265062f59cb98993ad016a Mon Sep 17 00:00:00 2001 From: Sophie Taylor Date: Thu, 17 Apr 2025 11:34:06 +1000 Subject: [PATCH] types: add domain-label, fqdn --- dns/types/simple.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dns/types/simple.nix b/dns/types/simple.nix index 3e089a8..e15cc3a 100644 --- a/dns/types/simple.nix +++ b/dns/types/simple.nix @@ -7,9 +7,21 @@ let inherit (builtins) stringLength; + # RFC 1035, 3.1 + domain-name = lib.types.addCheck lib.types.nonEmptyStr (s: stringLength s <= 255) // { + description = "an RFC 1035 DNS domain name"; + }; in { - # RFC 1035, 3.1 - domain-name = lib.types.addCheck lib.types.str (s: stringLength s <= 255); + inherit domain-name; + + # RFC 2181, section 11 + domain-label = lib.types.addCheck lib.types.nonEmptyStr (s: stringLength s <= 63) // { + description = "a DNS label"; + }; + + fqdn = lib.types.addCheck domain-name (lib.strings.hasSuffix ".") // { + description = "a fully-qualified DNS domain name"; + }; }