3
0
Fork 0
forked from mirrors/nixpkgs

nixos: default nix.maxJobs to auto

Instead of making the configuration less portable by hard coding the number of
jobs equal to the cores we can also let nix set the same number at runtime.
This commit is contained in:
Jörg Thalheim 2020-04-07 08:21:02 +01:00
parent 5d3f4e9c0b
commit e6a15db534
No known key found for this signature in database
GPG key ID: 003F2096411B5F92
2 changed files with 6 additions and 9 deletions

View file

@ -91,9 +91,6 @@ sub hasCPUFeature {
}
# Detect the number of CPU cores.
my $cpus = scalar (grep {/^processor\s*:/} (split '\n', $cpuinfo));
# Determine CPU governor to use
if (-e "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors") {
@ -562,7 +559,6 @@ my $hwConfig = <<EOF;
boot.kernelModules = [$kernelModules ];
boot.extraModulePackages = [$modulePackages ];
$fsAndSwap
nix.maxJobs = lib.mkDefault $cpus;
${\join "", (map { " $_\n" } (uniq @attrs))}}
EOF

View file

@ -92,13 +92,14 @@ in
maxJobs = mkOption {
type = types.either types.int (types.enum ["auto"]);
default = 1;
default = "auto";
example = 64;
description = ''
This option defines the maximum number of jobs that Nix will try
to build in parallel. The default is 1. You should generally
set it to the total number of logical cores in your system (e.g., 16
for two CPUs with 4 cores each and hyper-threading).
This option defines the maximum number of jobs that Nix will try to
build in parallel. The default is auto, which means it will use all
available logical cores. It is recommend to set it to the total
number of logical cores in your system (e.g., 16 for two CPUs with 4
cores each and hyper-threading).
'';
};