Is your feature request related to a problem?
When rebuilding a running server, I would like to avoid impacting normal operations too much, so I would like Nix builds to keep one CPU core available.
Proposed solution
Allow the cores setting in nix.conf to be set to a negative value, which is then added to the detected number of CPU cores in the same way that 0 means “use the detected number of cores”. For example, a value of -1 would use all cores except for one. For convenience, the value should be clamped to a lower bound of 1, to allow using the same config on a single-core device.
Alternative solutions
Manually calculate this number for each configured device, and manually update it when migrating to different hardware.
Additional context
See Cargo's --jobs (-j) flag for prior art.
Checklist
Add 👍 to issues you find important.
Is your feature request related to a problem?
When rebuilding a running server, I would like to avoid impacting normal operations too much, so I would like Nix builds to keep one CPU core available.
Proposed solution
Allow the
coressetting in nix.conf to be set to a negative value, which is then added to the detected number of CPU cores in the same way that0means “use the detected number of cores”. For example, a value of-1would use all cores except for one. For convenience, the value should be clamped to a lower bound of 1, to allow using the same config on a single-core device.Alternative solutions
Manually calculate this number for each configured device, and manually update it when migrating to different hardware.
Additional context
See Cargo's
--jobs(-j) flag for prior art.Checklist
Add 👍 to issues you find important.