From ee0f7be746b2ac9f21cb128995266a5804912c0d Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 28 Apr 2025 16:12:03 +0700 Subject: [PATCH] breakpointHook: support FODs and non-sandboxed builds Remove the static reference to /build, instead evaluate NIX_BUILD_TOP --- pkgs/by-name/br/breakpointHook/attach.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/br/breakpointHook/attach.sh b/pkgs/by-name/br/breakpointHook/attach.sh index 0605adafdb62..afc192342fbc 100755 --- a/pkgs/by-name/br/breakpointHook/attach.sh +++ b/pkgs/by-name/br/breakpointHook/attach.sh @@ -56,6 +56,10 @@ elif [ "$(echo "$pids" | wc -l)" -ne 1 ]; then fi pid="$(echo "$pids" | head -n1)" + +# get the build top level directory inside the sandbox (eg. /build) +buildDir=$(getVar NIX_BUILD_TOP) + # bash is needed to load the env vars, as we do not know the syntax of the debug shell. # bashInteractive is used instead of bash, as we depend on it anyways, due to it being # the default debug shell @@ -71,11 +75,11 @@ pwd="$(readlink /proc/$pid/cwd)" # If another shell is chosen via `debugShell`, it will only have simple env vars avaialable. exec nsenter --mount --ipc --uts --pid --net --target "$pid" "$bashInteractive" -c " set -eu -o pipefail - source /build/env-vars + source \"$buildDir/env-vars\" cd \"$pwd\" if [ -n \"$debugShell\" ]; then exec \"$debugShell\" else - exec \"$bashInteractive\" --init-file /build/env-vars + exec \"$bashInteractive\" --init-file \"$buildDir/env-vars\" fi "