Starting PDB within Python Build in mkDerivation

I have a build that is failing due to some python code that has to run within the build step of a mkDerivation. I am using python 3.7 and was hoping that I could use breakpoint() on a line within the code to start pdb within the build process instead of print statements. Is this possible?

You don’t get access usually to stdin/stdout. However you can use on Linux breakpointHook that was recently added to let the build fail at some point. Then you can attach with cntr and get an interactive shell where you rerun the same command. At the moment there is still a bug in cntr that prevents the creation of /var/lib/cntr when used in combination with nix. Just create as root on your host that directory before running cntr.