From d33c97ec1b3f26d6a2d4d6ec0246af48a1a2259d Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Wed, 20 May 2026 09:22:55 -0500 Subject: [PATCH] lib/strings: add isPathLike helper --- modules/lib/strings.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/lib/strings.nix b/modules/lib/strings.nix index e8e700c51..92e0d7023 100644 --- a/modules/lib/strings.nix +++ b/modules/lib/strings.nix @@ -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; }