If I build many derivations, nix-build -j 8 --cores 8
will make them build in parallel which will often be faster. If I build only one derivation, will -j 8
or --cores 8
affect the parallelism of the build?
1 Like
--cores
does affect parallelism of a single derivation build. I’m guessing -j
doesn’t.
--cores
Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders. Builders can use this variable at their
discretion to control the maximum amount of parallelism. For instance, in Nixpkgs, if the derivation attribute
enableParallelBuilding is set to true, the builder passes the -jN flag to GNU Make. It defaults to the value of the cores
configuration setting, if set, or 1 otherwise. The value 0 means that the builder should use all available CPU cores in the
system.
--max-jobs / -j number
Sets the maximum number of build jobs that Nix will perform in parallel to the specified number. Specify auto to use the number
of CPUs in the system. The default is specified by the max-jobs configuration setting, which itself defaults to 1. A higher value
is useful on SMP systems or to exploit I/O latency.
Setting it to 0 disallows building on the local machine, which is useful when you want builds to happen only on remote builders.
2 Likes