refactor(nix): move isPathLike utility into //nix/utils

Change-Id: I040fbcbf1eefa69a2e37bf6e40fa6bc453ea1c90
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13179
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: sterni <sternenseemann@systemli.org>
This commit is contained in:
sterni 2025-02-26 22:57:44 +01:00 committed by clbot
parent 13723eb45f
commit 699826b831
2 changed files with 24 additions and 7 deletions

View file

@ -148,6 +148,27 @@ let
*/
isSymlink = path: pathType' path ? symlink;
/* Checks whether the given value is (or contains) a reference to a
path that will be retained in the store path resulting from a derivation.
So if isReferencablePath returns true, the given value may be used in a
way that allows accessing it at runtime of any Nix built program.
Returns true for:
- Strings with context (if the string is/contains a single path is not verified!)
- Path values
- Derivations
Note that the value still needs to used in a way that forces string context
(and thus reference tracking) to be created, e.g. in string interpolation.
Type: any -> bool
*/
isReferencablePath = value:
builtins.isPath value
|| lib.isDerivation value
|| (builtins.isString value && builtins.hasContext value);
in
{
inherit
@ -156,5 +177,6 @@ in
isDirectory
isRegularFile
isSymlink
isReferencablePath
;
}