summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorRyan Trinkle <ryan.trinkle@gmail.com>2017-12-02 13:04:16 -0500
committerRyan Trinkle <ryan.trinkle@gmail.com>2017-12-02 13:28:00 -0500
commit83048c4fe02d69a4f0d7e832fbca30d21813ece3 (patch)
tree76f94ae045d383f879f5cddde24ec5f6ad9e885e /lib
parent6281eb123bcdefcaebbd973600f4d33772012025 (diff)
downloadnixpkgs-83048c4fe02d69a4f0d7e832fbca30d21813ece3.tar
nixpkgs-83048c4fe02d69a4f0d7e832fbca30d21813ece3.tar.gz
nixpkgs-83048c4fe02d69a4f0d7e832fbca30d21813ece3.tar.bz2
nixpkgs-83048c4fe02d69a4f0d7e832fbca30d21813ece3.tar.lz
nixpkgs-83048c4fe02d69a4f0d7e832fbca30d21813ece3.tar.xz
nixpkgs-83048c4fe02d69a4f0d7e832fbca30d21813ece3.tar.zst
nixpkgs-83048c4fe02d69a4f0d7e832fbca30d21813ece3.zip
nixpkgs.lib: Add types.strMatching
Diffstat (limited to 'lib')
-rw-r--r--lib/types.nix7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/types.nix b/lib/types.nix
index 46ed05d288f..88fc90d0597 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -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 {