Skip to content

Allow negative value for cores setting #15740

@fenhl

Description

@fenhl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposal
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions