By: Tom Sydney Kerckhove <syd@cs-syd.eu>
Respect the cores nix gave the build A test suite compiled with -N asks the RTS for every core of the machine it runs on, which inside a nix build is not what the build was given. Nix's cores setting reaches a build only as NIX_BUILD_CORES, so read that, and let it decide how parallel to run when nothing else does. Nix's --max-jobs is not visible to a build at all, so there is nothing to respect there. It narrows only the ByCapabilities case. Anything configured explicitly still decides: --jobs, --synchronous, SYDTEST_JOBS, threads in the config file, and --debug all win, so an ambient variable cannot override a config file. The narrowing also happens after the warning about compiling with -N is decided, so a suite stuck on one capability is still told to add it rather than silently running n-way on one core. Zero threads now means every capability rather than an asynchronous runner with no workers. --jobs 0 left nothing to take tests off the queue and the suite died with "thread blocked indefinitely in an STM transaction". Nix documents 0 as "use every core", and the mutation driver's own job counts have always treated it that way, so every route into a thread count now agrees.