Skip to content

Commit

Permalink
no-broken-symlinks: actually interpolate relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorBaker committed Jan 23, 2025
1 parent 51b2764 commit 34539b2
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pkgs/build-support/setup-hooks/no-broken-symlinks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,9 @@ noBrokenSymlinks() {
nixInfoLog "symlink $path points to absolute target $symlinkTarget"
else
nixInfoLog "symlink $path points to relative target $symlinkTarget"
symlinkTarget="$pathParent/$symlinkTarget"

# Check to make sure the interpolated target doesn't escape the store path of `output`.
# If it does, Nix probably won't be able to resolve or track dependencies.
if [[ $symlinkTarget != "$output" && $symlinkTarget != "$output"/* ]]; then
nixErrorLog "symlink $path points to target $symlinkTarget, which escapes the current store path $output"
exit 1
fi
# Use --no-symlinks to avoid dereferencing again and --canonicalize-missing to avoid existence
# checks at this step (which can lead to infinite recursion).
symlinkTarget="$(realpath --no-symlinks --canonicalize-missing "$pathParent/$symlinkTarget")"
fi

if [[ $path == "$symlinkTarget" ]]; then
Expand Down

0 comments on commit 34539b2

Please sign in to comment.