nixpkgs.lib: Add types.strMatching

This commit is contained in:
Ryan Trinkle
2017-12-02 13:04:16 -05:00
parent 6281eb123b
commit 83048c4fe0
2 changed files with 13 additions and 0 deletions

View File

@@ -174,6 +174,13 @@ rec {
merge = mergeOneOption;
};
strMatching = pattern: mkOptionType {
name = "strMatching ${escapeNixString pattern}";
description = "string matching the pattern ${pattern}";
check = x: str.check x && builtins.match pattern x != null;
inherit (str) merge;
};
# Merge multiple definitions by concatenating them (with the given
# separator between the values).
separatedString = sep: mkOptionType rec {