Home Explore Blog Models CI



nixpkgs

doc/hooks/breakpoint.section.md
1d6139649ce4f72cc4cc6f576b67930af947edd92c21491c00000003000003bd
# breakpointHook {#breakpointhook}

This hook makes a build pause instead of stopping when a failure occurs. It prevents Nix from cleaning up the build environment immediately and allows the user to attach to the build environment. Upon a build error, it will print instructions that can be used to enter the environment for debugging. The `breakpointHook` is only available on Linux. To use it, add `breakpointHook` to `nativeBuildInputs` in the package to be inspected.

```nix
{ nativeBuildInputs = [ breakpointHook ]; }
```

When a build failure occurs, an instruction will be printed showing how to attach to the build sandbox.

::: {.note}
Caution with remote builds

For remote builds, the printed instructions need to be run on the remote machine, as the build sandbox is only accessible on the machine running the builds. Remote builds can be turned off by setting `--option builders ''` for `nix-build` or `--builders ''` for `nix build`. :::
:::

Chunks
568c5566 (1st chunk of `doc/hooks/breakpoint.section.md`)
Title: Nix breakpointHook for Debugging Build Failures
Summary
The `breakpointHook` in Nix allows builds to pause on failure instead of stopping, preventing immediate cleanup of the build environment. This enables users to attach to the build sandbox for debugging. Available only on Linux, it's activated by adding `breakpointHook` to `nativeBuildInputs`. Upon an error, it prints instructions for accessing the environment. Users should be cautious with remote builds, as debugging must occur on the remote machine where the build sandbox resides; remote builds can be disabled if needed.