Nix: Add supportedFeatures support for local builds

Created on 27 Mar 2018  路  10Comments  路  Source: NixOS/nix

The requiredSystemFeatures derivation attribute is a useful feature for limiting the set of machines on which a build can be performed. But, this can never include the local machine, as there is no way to specify what supportedFeatures there are for the local machine. The effective result of this is that there's no way to prevent a build from happening on the local machine if the local machine does not have the requiredSystemFeatures. For example, if you can't have Nix using the kvm feature, and you would want to exclude any build which lists kvm as a requiredSystemFeature from running on the local machine.

Proposal: add a nix.supportedFeatures NixOS option which allows you to specify the supported features of the local system, to prevent certain kinds of builds from running on the local system.

Most helpful comment

Extending this discussion a bit... it would be nice if the distributed building semantics mirrored more or less what the Hydra ones are. i.e., turning on distributedBuilds would mean that you have to specify each machine to use, including the local machine. Exposing this through the existing build machines mechanism might be better than adding dedicated nix options for "local" supported features/mandatoryFeatures

All 10 comments

As a workaround, you can add the local machine as a remote builder, then run a build with --option build-max-jobs 0 to forbid direct local builds (local builds via self-remote will use some combination of config values from nix.conf and the remote machine list)

@7c6f434c Unfortunately adding the local machine as a remote builder creates a deadlock. See https://github.com/NixOS/nix/issues/2029

Similar to this, I would like to set a speed factor on the local machine. For now, the build seems to always prefer remotes (as if the local machine had an implicit speed factor of 0).

I'm noticing exactly what @timokau said. Further, when building on my desktop, I want the local machine preferred over the laptop; but when building on the laptop, I want the desktop to be preferred. If everything was considered a remote machine, I could use speedFactor to correctly balance between all the machines in my house, even using the same configuration on all of them. This fundamental difference between the local machine and all the remote machines is confusing and unfortunate. It's like a remote machine with a speedFactor of -1 that cannot have supported features listed.

@shlevy How hard is this to do?

This should be pretty easy to implement.

Extending this discussion a bit... it would be nice if the distributed building semantics mirrored more or less what the Hydra ones are. i.e., turning on distributedBuilds would mean that you have to specify each machine to use, including the local machine. Exposing this through the existing build machines mechanism might be better than adding dedicated nix options for "local" supported features/mandatoryFeatures

1e7b8de does not address setting the speed factor for the local machine right? Should I open a separate issue for that?

Yeah, it doesn't address the speed factor.

Follow up in #2457. Thanks for the fix in 1e7b8de!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drewm1980 picture drewm1980  路  3Comments

matthewbauer picture matthewbauer  路  3Comments

eqyiel picture eqyiel  路  3Comments

Infinisil picture Infinisil  路  3Comments

copumpkin picture copumpkin  路  3Comments