Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport breakpointHook [18.09] #49099

Merged
merged 4 commits into from Oct 26, 2018
Merged

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Oct 25, 2018

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

(cherry picked from commit 84e915a)
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.

(cherry picked from commit f10b935)
(cherry picked from commit 325a569)
@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: breakpointHook

The following builds were skipped because they don't evaluate on aarch64-linux: cntr

Partial log (click to expand)

copying path '/nix/store/ck0x3a6c5g3764cdsrds5h4bgy0xmfyp-coreutils-8.29' from 'https://cache.nixos.org'...
copying path '/nix/store/6bjfc900zpkn6mxxhbh7y4dcnrnnfdk2-gnutar-1.30' from 'https://cache.nixos.org'...
copying path '/nix/store/v3qg6ra48fyc06jcw04ma0q4kixl452i-bzip2-1.0.6.0.1-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/591702m05jkg4b0qigqbx8rnxfzzsvbf-gnugrep-3.1' from 'https://cache.nixos.org'...
copying path '/nix/store/62gd6xxj27mm48pkpg5w9jx06fvqq86c-patchelf-0.9' from 'https://cache.nixos.org'...
copying path '/nix/store/rwy3kl2wc4d397w4pmd8iyxm9ysyspcp-diffutils-3.6' from 'https://cache.nixos.org'...
copying path '/nix/store/lisaqi3a0cd2ixvpzb2wbz4a32hpzb6g-findutils-4.6.0' from 'https://cache.nixos.org'...
copying path '/nix/store/1186vdl1vwrvpmihrwjq4sil1k37fana-stdenv-linux' from 'https://cache.nixos.org'...
building '/nix/store/imf65gxhn1m3v23b7gbf7rvf8wmnyvxc-hook.drv'...
/nix/store/4m5q3ckqpc8h4vjxzsvkym1plp29v81d-hook

@GrahamcOfBorg
Copy link

No attempt on x86_64-darwin (full log)

The following builds were skipped because they don't evaluate on x86_64-darwin: breakpointHook, cntr

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: breakpointHook, cntr

Partial log (click to expand)

installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/5fhjbrrfws7k3lr92xrz3l7lxbij7ppi-cntr-1.2.0
shrinking /nix/store/5fhjbrrfws7k3lr92xrz3l7lxbij7ppi-cntr-1.2.0/bin/cntr
strip is /nix/store/h0lbngpv6ln56hjj59i6l77vxq25flbz-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/5fhjbrrfws7k3lr92xrz3l7lxbij7ppi-cntr-1.2.0/bin
patching script interpreter paths in /nix/store/5fhjbrrfws7k3lr92xrz3l7lxbij7ppi-cntr-1.2.0
checking for references to /build in /nix/store/5fhjbrrfws7k3lr92xrz3l7lxbij7ppi-cntr-1.2.0...
/nix/store/0m0w3s7a0da17qz206rlvs4k3pa58acd-hook
/nix/store/5fhjbrrfws7k3lr92xrz3l7lxbij7ppi-cntr-1.2.0

doc/stdenv.xml Outdated
This hook will make a build pause instead of stopping
when a failure happen. It prevents nix to cleanup the build
environment immediatly and allows the user to attach
to a build environemnt using the <varname>cntr</varname> command.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<command> is probably better suited for this

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: breakpointHook

The following builds were skipped because they don't evaluate on aarch64-linux: cntr

Partial log (click to expand)


b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


these derivations will be built:
  /nix/store/imf65gxhn1m3v23b7gbf7rvf8wmnyvxc-hook.drv
building '/nix/store/imf65gxhn1m3v23b7gbf7rvf8wmnyvxc-hook.drv'...
/nix/store/4m5q3ckqpc8h4vjxzsvkym1plp29v81d-hook

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: breakpointHook, cntr

Partial log (click to expand)

installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/8qglbfh1yd4ny25q60nazzkxrqd4xkzn-cntr-1.2.0
shrinking /nix/store/8qglbfh1yd4ny25q60nazzkxrqd4xkzn-cntr-1.2.0/bin/cntr
strip is /nix/store/h0lbngpv6ln56hjj59i6l77vxq25flbz-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/8qglbfh1yd4ny25q60nazzkxrqd4xkzn-cntr-1.2.0/bin
patching script interpreter paths in /nix/store/8qglbfh1yd4ny25q60nazzkxrqd4xkzn-cntr-1.2.0
checking for references to /build in /nix/store/8qglbfh1yd4ny25q60nazzkxrqd4xkzn-cntr-1.2.0...
/nix/store/0m0w3s7a0da17qz206rlvs4k3pa58acd-hook
/nix/store/8qglbfh1yd4ny25q60nazzkxrqd4xkzn-cntr-1.2.0

@GrahamcOfBorg
Copy link

No attempt on x86_64-darwin (full log)

The following builds were skipped because they don't evaluate on x86_64-darwin: breakpointHook, cntr

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@Mic92 Mic92 merged commit c2ad4bf into NixOS:release-18.09 Oct 26, 2018
@Mic92 Mic92 deleted the breakpoint-backport branch October 26, 2018 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants