diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2018-06-22 12:12:40 +0100 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2018-10-25 10:19:41 +0100 |
commit | f10b935f84d068f616f335ad75a99f13af35337a (patch) | |
tree | 7a27cea930392f3af38b8a2144c2be4c86bf1306 /pkgs/build-support | |
parent | 84e915a779b456b51a5368d6b0ec8d095ffedeb9 (diff) | |
download | nixlib-f10b935f84d068f616f335ad75a99f13af35337a.tar nixlib-f10b935f84d068f616f335ad75a99f13af35337a.tar.gz nixlib-f10b935f84d068f616f335ad75a99f13af35337a.tar.bz2 nixlib-f10b935f84d068f616f335ad75a99f13af35337a.tar.lz nixlib-f10b935f84d068f616f335ad75a99f13af35337a.tar.xz nixlib-f10b935f84d068f616f335ad75a99f13af35337a.tar.zst nixlib-f10b935f84d068f616f335ad75a99f13af35337a.zip |
breakpointHook: add for debugging failing builds
Usuage: Add breakpointHook to your `buildInputs` like this: stdenv.mkDerivation rec { # ... buildInputs = [ breakpointHook ]; }); When the build fails as show in this example: pkgs.hello.overrideAttrs (old: { buildInputs = [ breakpointHook ]; postPatch = '' false ''; }); It will halt execution printing the following message: build failed in patchPhase with exit code 1 To attach to this build run the following command as root: cntr attach -t command cntr-/nix/store/ynyb4n82x2r7sldd58pbb405jdqh5f00-hello-2.10 Installing cntr and running the command will provide shell access to the build sandbox of failed build: sudo cntr attach -t command cntr-/nix/store/ynyb4n82x2r7sldd58pbb405jdqh5f00-hello-2.10 WARNING: bad ownership on /nix/var/nix/profiles/per-user/root, should be 1000 [nixbld@localhost:/var/lib/cntr]$ At /var/lib/cntr the sandbox filesystem is mounted. All commands and files of the system are still accessible within the shell. To execute commands from the sandbox use the `cntr exec` subcommand.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/setup-hooks/breakpoint-hook.sh | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/breakpoint-hook.sh b/pkgs/build-support/setup-hooks/breakpoint-hook.sh new file mode 100644 index 000000000000..6bef786ac3ac --- /dev/null +++ b/pkgs/build-support/setup-hooks/breakpoint-hook.sh @@ -0,0 +1,9 @@ +breakpointHook() { + local red='\033[0;31m' + local no_color='\033[0m' + + echo -e "${red}build failed in ${curPhase} with exit code ${exitCode}${no_color}" + printf "To attach install cntr and run the following command as root:\n\n" + sh -c "echo ' cntr attach -t command cntr-${out}'; while true; do sleep 99999999; done" +} +failureHooks+=(breakpointHook) |