diff --git a/lib/make-disk-image.nix b/lib/make-disk-image.nix index 8c3d550..2e1b55f 100644 --- a/lib/make-disk-image.nix +++ b/lib/make-disk-image.nix @@ -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 "" diff --git a/module.nix b/module.nix index 421efcf..1094a5c 100644 --- a/module.nix +++ b/module.nix @@ -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.