Admins will be upgrading ORNL GitLab Servers on Saturday, 16 May 2026, from 7 AM until 11 AM EST. Repositories will experience intermittent outages during this time.
in/* No rec! Add dependencies on this file at the top. */{
/* Append a subpath string to a path.
@@ -108,6 +126,12 @@ in /* No rec! Add dependencies on this file at the top. */ {
More specifically, it checks that the first argument is a [path value type](https://nixos.org/manual/nix/stable/language/values.html#type-path"),
and that the second argument is a valid subpath string (see `lib.path.subpath.isValid`).
Laws:
- Not influenced by subpath normalisation
append p s == append p (subpath.normalise s)
Type:
append :: Path -> String -> Path
@@ -149,6 +173,51 @@ in /* No rec! Add dependencies on this file at the top. */ {
${subpathInvalidReasonsubpath}'';
path+("/"+subpath);
/*
Whether the first path is a component-wise prefix of the second path.
Laws:
- `hasPrefix p q` is only true if `q == append p s` for some subpath `s`.
- `hasPrefix` is a [non-strict partial order](https://en.wikipedia.org/wiki/Partially_ordered_set#Non-strict_partial_order) over the set of all path values
Type:
hasPrefix :: Path -> Path -> Bool
Example:
hasPrefix /foo /foo/bar
=> true
hasPrefix /foo /foo
=> true
hasPrefix /foo/bar /foo
=> false
hasPrefix /. /foo
=> true
*/
hasPrefix=
path1:
assertassertMsg
(isPathpath1)
"lib.path.hasPrefix: First argument is of type ${typeOfpath1}, but a path was expected";
let
path1Deconstructed=deconstructPathpath1;
in
path2:
assertassertMsg
(isPathpath2)
"lib.path.hasPrefix: Second argument is of type ${typeOfpath2}, but a path was expected";