Nix: connecting to the Sandbox

19 Likes

Something which is also not well known:

You can do nix develop and then run through all the “phases” of the derivation and see what part fails.

Look like Nix-build-phases: run nix build phases interactively has a nice UX around it.

11 Likes

This script was renamed to nix-develop-interactive and it contains usage instructions inside.

Recently I have integrated it in to Nix Forge so it can be enabled by simple setting debug = true; in a package recipe.

3 Likes

Another approach that has been useful in various situations, use tmate! trivial-builders: init addTmateBreakpoint by MatthewCroughan · Pull Request #334924 · NixOS/nixpkgs · GitHub

6 Likes

All these years without even knowing such a thing existed… Thank you !

3 Likes

tmate maintainer says: “I’m closing the servers permanently”

3 Likes

Oh no :frowning:
any good alternatives?

There are some alternatives being discussed in that github issue.

1 Like

Very cool blog! Thank you!

It would be amazing to get some of this info added into some the tutorials, and/or other docs. - Sorry, but I’m not sure the best ones to put it into.

I wish I’d known about this about a week ago! :laughing:

      nativeBuildInputs = [
        # add the breakpoint hook
        pkgs.breakpointHook
      ];
2 Likes

Oh nice!
This kind of reminds me the builtins.break feature which allows to open an interactive repl anywhere during the evaluation (to debug), in case anyone interested.

3 Likes