Running out of file handles when using remote builders

Hi! I’ve configured a NixOS machine to use another machine as a remote builder. When I run something like nix flake check "./path" --max-jobs 0, the other machine is used as intended.

I use crane, where each dependency involves a curl download task, for larger projects leading to hundreds or even thousands of derivations.

What I then observe is that the number of ‘active’ jobs (the left-most number) will increase for a long time (might get into the hundreds) and eventually may error with error: creating pipe: Too many open files.

I’m registering my builder like

  nix.buildMachines = [
      hostName = "hostname";
      system = "aarch64-darwin";
      protocol = "ssh-ng";
      maxJobs = 8;

and this ends up in the machines block as

ssh-ng://hostname aarch64-darwin - 8 1 - - -

It almost feels like the machine is finishing jobs too quickly, so it just keeps scheduling more and more of them. Has anyone else seen issues like this and are there any known mitigations? I’ve tried increasing the soft limit in terms of file handles but it still errors.