lib/strings: add isPathLike helper
This commit is contained in:
parent
eaca478c95
commit
d33c97ec1b
1 changed files with 7 additions and 0 deletions
|
|
@ -87,4 +87,11 @@ rec {
|
|||
# Returns true for strings like `SCREAMING_SNAKE_CASE`, `SOME_CONSTANT`.
|
||||
# Must be all uppercase letters/numbers, with words separated by single underscores.
|
||||
isScreamingSnakeCase = str: builtins.match "^[A-Z0-9]+(_[A-Z0-9]+)*$" str != null;
|
||||
|
||||
# Check if the content is path-like (a path, a Nix store path string, or a derivation).
|
||||
isPathLike =
|
||||
content:
|
||||
lib.isPath content
|
||||
|| (builtins.isString content && lib.hasPrefix "${builtins.storeDir}/" content)
|
||||
|| lib.isDerivation content;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue