disko-images: add copyNixStoreThreads option for configurable parallelism
Allow users to override the automatic thread count detection for nix store copying. The default "auto" behavior remains unchanged (min of nproc and 8), but users can now specify a fixed thread count for environments where the automatic detection isn't optimal.
This commit is contained in:
committed by
Jörg Thalheim
parent
10cdd63203
commit
8e68aa819d
+10
-1
@@ -153,7 +153,16 @@ let
|
||||
# systems, while -P 4 is ~30% slower. Cap at 8 but use fewer workers if the
|
||||
# system has fewer cores.
|
||||
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
|
||||
P=$(nproc); [ "$P" -gt 8 ] && P=8
|
||||
${
|
||||
if cfg.copyNixStoreThreads == "auto" then
|
||||
''
|
||||
P=$(nproc); [ "$P" -gt 8 ] && P=8
|
||||
''
|
||||
else
|
||||
''
|
||||
P=${toString cfg.copyNixStoreThreads}
|
||||
''
|
||||
}
|
||||
xargs -P "$P" -I {} cp --recursive {} ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
|
||||
|
||||
${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --root ${systemToInstall.config.disko.rootMountPoint} --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches ""
|
||||
|
||||
+12
@@ -106,6 +106,18 @@ in
|
||||
default = true;
|
||||
};
|
||||
|
||||
copyNixStoreThreads = lib.mkOption {
|
||||
type = lib.types.either lib.types.ints.positive (lib.types.enum [ "auto" ]);
|
||||
description = ''
|
||||
Number of parallel threads to use when copying the nix store.
|
||||
Set to "auto" (the default) to automatically determine based on CPU cores,
|
||||
capped at 8. Higher values may hurt performance on some systems due to
|
||||
virtiofsd file descriptor limits.
|
||||
'';
|
||||
default = "auto";
|
||||
example = 4;
|
||||
};
|
||||
|
||||
extraConfig = lib.mkOption {
|
||||
description = ''
|
||||
Extra NixOS config for your test. Can be used to specify a different luks key for tests.
|
||||
|
||||
Reference in New Issue
Block a user