Skip to content

Commit ee0f7be

Browse files
committed
breakpointHook: support FODs and non-sandboxed builds
Remove the static reference to /build, instead evaluate NIX_BUILD_TOP
1 parent 1b58ccc commit ee0f7be

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkgs/by-name/br/breakpointHook/attach.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ elif [ "$(echo "$pids" | wc -l)" -ne 1 ]; then
5656
fi
5757
pid="$(echo "$pids" | head -n1)"
5858

59+
60+
# get the build top level directory inside the sandbox (eg. /build)
61+
buildDir=$(getVar NIX_BUILD_TOP)
62+
5963
# bash is needed to load the env vars, as we do not know the syntax of the debug shell.
6064
# bashInteractive is used instead of bash, as we depend on it anyways, due to it being
6165
# the default debug shell
@@ -71,11 +75,11 @@ pwd="$(readlink /proc/$pid/cwd)"
7175
# If another shell is chosen via `debugShell`, it will only have simple env vars avaialable.
7276
exec nsenter --mount --ipc --uts --pid --net --target "$pid" "$bashInteractive" -c "
7377
set -eu -o pipefail
74-
source /build/env-vars
78+
source \"$buildDir/env-vars\"
7579
cd \"$pwd\"
7680
if [ -n \"$debugShell\" ]; then
7781
exec \"$debugShell\"
7882
else
79-
exec \"$bashInteractive\" --init-file /build/env-vars
83+
exec \"$bashInteractive\" --init-file \"$buildDir/env-vars\"
8084
fi
8185
"

0 commit comments

Comments
 (0)