Skip to content

types: add domain-label, fqdn #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions dns/types/simple.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
}