How to stop a runaway nix build job

While playing around with pytorch/CUDA in and flake and using direnv for automatic environment switching, nix started a complete compilation of torchWithCuda. No surprises there:I wanted to verify that this was going to happen, before trying the numtide binary cache.

At first, Control-C in the shell in which direnv launched the compilation, was enough to interrupt it. But somehow I have managed to get into the state where the compilation is continuing (maxing out all my CPUs) even though the direnv shell which started it all is no longer open.

How can I stop this nix build?

in typical unix fashion there is about a million ways to do this from the shell.

let the best KILL command win.

Trouble is, the relevant processes are owned by nixbldN and their pids are changing (subjobs completing) faster than I can track them down by hand and I’m nervous about killing multiple things via sudo, etc. etc.

So, what exactly should I kill?

Anyway, it seems to have stopped. Waaaay sooner than the whole build should have taken. Maybe it’s some part of the whole process that ran to completion. It’s going to be pretty difficult to post-mortem this.

you can run pstree to find the top process, you can kill and restart the nix daemon, it usually survives and recovers quite gracefully, its quite indestructible. .