From a3c5f0cba8fa9c4d9782ef83757be6e4028f54b7 Mon Sep 17 00:00:00 2001 From: Artturin Date: Tue, 20 Jul 2021 05:17:35 +0300 Subject: [PATCH] lib/types.nix: add nonEmptyStr --- lib/types.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/types.nix b/lib/types.nix index f47a1f92de7..68262951a13 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -287,6 +287,13 @@ rec { merge = mergeEqualOption; }; + nonEmptyStr = mkOptionType { + name = "nonEmptyStr"; + description = "non-empty string"; + check = x: str.check x && builtins.match "[ \t\n]*" x == null; + inherit (str) merge; + }; + strMatching = pattern: mkOptionType { name = "strMatching ${escapeNixString pattern}"; description = "string matching the pattern ${pattern}";