I’m wondering if it’s possible to limit the system resources of a Nix build via cgroups or something similar. My usecase is for building lots of things in parallel in continuous integration. I’d like all the parallel builds to have a maximum number of CPU time and/or memory.
Is this possible, considering the user running
nix-build isn’t the one that actually performs the build? The Nix daemon assigns the build to one of the
nixbld* users, which is chosen at random, so how can I constrain a Nix build’s resources?
I’m really trying to avoid using containers or virtual machines in this scenario, since a lot of the builds involve NixOS tests and I don’t want nested virtualization.