summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2020-04-07 08:21:02 +0100
committerJörg Thalheim <joerg@thalheim.io>2020-04-07 08:45:56 +0100
commite6a15db534d18d0eefb5916ee87b4951d51af2cf (patch)
tree69d2eb71b8dbb7fb0debecdefa253b1c3b844074 /nixos/modules
parent5d3f4e9c0b9c3ccfbd48e5b472ad064215fd4a28 (diff)
downloadnixpkgs-e6a15db534d18d0eefb5916ee87b4951d51af2cf.tar
nixpkgs-e6a15db534d18d0eefb5916ee87b4951d51af2cf.tar.gz
nixpkgs-e6a15db534d18d0eefb5916ee87b4951d51af2cf.tar.bz2
nixpkgs-e6a15db534d18d0eefb5916ee87b4951d51af2cf.tar.lz
nixpkgs-e6a15db534d18d0eefb5916ee87b4951d51af2cf.tar.xz
nixpkgs-e6a15db534d18d0eefb5916ee87b4951d51af2cf.tar.zst
nixpkgs-e6a15db534d18d0eefb5916ee87b4951d51af2cf.zip
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.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl4
-rw-r--r--nixos/modules/services/misc/nix-daemon.nix11
2 files changed, 6 insertions, 9 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index 629c56814a1..a32c19a4eba 100644
--- a/nixos/modules/installer/tools/nixos-generate-config.pl
+++ b/nixos/modules/installer/tools/nixos-generate-config.pl
@@ -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
 
diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix
index 8203cb13e50..e14df310ae8 100644
--- a/nixos/modules/services/misc/nix-daemon.nix
+++ b/nixos/modules/services/misc/nix-daemon.nix
@@ -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).
         '';
       };