mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
Parser: Respect the accessor of the source file for relative paths
Previously we only returned paths in rootFS, which is wrong and only worked because currently all our source trees are in rootFS.
This commit is contained in:
parent
5c6785e0c1
commit
7096acc74d
1 changed files with 11 additions and 4 deletions
|
@ -359,11 +359,18 @@ string_parts_interpolated
|
|||
|
||||
path_start
|
||||
: PATH {
|
||||
Path path(absPath(std::string_view{$1.p, $1.l}, state->basePath.path.abs()));
|
||||
std::string_view literal({$1.p, $1.l});
|
||||
Path path(absPath(literal, state->basePath.path.abs()));
|
||||
/* add back in the trailing '/' to the first segment */
|
||||
if ($1.p[$1.l-1] == '/' && $1.l > 1)
|
||||
path += "/";
|
||||
$$ = new ExprPath(ref<SourceAccessor>(state->rootFS), std::move(path));
|
||||
if (literal.size() > 1 && literal.back() == '/')
|
||||
path += '/';
|
||||
$$ =
|
||||
/* Absolute paths are always interpreted relative to the
|
||||
root filesystem accessor, rather than the accessor of the
|
||||
current Nix expression. */
|
||||
literal.front() == '/'
|
||||
? new ExprPath(state->rootFS, std::move(path))
|
||||
: new ExprPath(state->basePath.accessor, std::move(path));
|
||||
}
|
||||
| HPATH {
|
||||
if (state->settings.pureEval) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue