nix_setup/cp: remove xcp again
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
mkdir -p "$CLAN_TEST_STORE/nix/store"
|
mkdir -p "$CLAN_TEST_STORE/nix/store"
|
||||||
mkdir -p "$CLAN_TEST_STORE/nix/var/nix/gcroots"
|
mkdir -p "$CLAN_TEST_STORE/nix/var/nix/gcroots"
|
||||||
if [[ -n "''${closureInfo-}" ]]; then
|
if [[ -n "''${closureInfo-}" ]]; then
|
||||||
${pkgs.findutils}/bin/xargs ${pkgs.xcp}/bin/xcp --recursive --target-directory "$CLAN_TEST_STORE/nix/store" < "$closureInfo/store-paths"
|
${pkgs.findutils}/bin/xargs -P"$(nproc)" ${pkgs.coreutils}/bin/cp --recursive --reflink=auto --target-directory "$CLAN_TEST_STORE/nix/store" < "$closureInfo/store-paths"
|
||||||
${pkgs.nix}/bin/nix-store --load-db --store "$CLAN_TEST_STORE" < "$closureInfo/registration"
|
${pkgs.nix}/bin/nix-store --load-db --store "$CLAN_TEST_STORE" < "$closureInfo/registration"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
];
|
];
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
substituteInPlace nixos_test_lib/nix_setup.py \
|
substituteInPlace nixos_test_lib/nix_setup.py \
|
||||||
--replace '@xcp@' '${pkgs.xcp}/bin/xcp' \
|
--replace '@cp@' '${pkgs.coreutils}/bin/cp' \
|
||||||
--replace '@nix-store@' '${pkgs.nix}/bin/nix-store' \
|
--replace '@nix-store@' '${pkgs.nix}/bin/nix-store' \
|
||||||
--replace '@xargs@' '${pkgs.findutils}/bin/xargs'
|
--replace '@xargs@' '${pkgs.findutils}/bin/xargs'
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# These paths will be substituted during package build
|
# These paths will be substituted during package build
|
||||||
XCP_BIN = "@xcp@"
|
CP_BIN = "@cp@"
|
||||||
NIX_STORE_BIN = "@nix-store@"
|
NIX_STORE_BIN = "@nix-store@"
|
||||||
XARGS_BIN = "@xargs@"
|
XARGS_BIN = "@xargs@"
|
||||||
|
|
||||||
@@ -45,15 +45,18 @@ def setup_nix_in_nix(closure_info: str | None) -> None:
|
|||||||
if closure_info and Path(closure_info).exists():
|
if closure_info and Path(closure_info).exists():
|
||||||
store_paths_file = Path(closure_info) / "store-paths"
|
store_paths_file = Path(closure_info) / "store-paths"
|
||||||
if store_paths_file.exists():
|
if store_paths_file.exists():
|
||||||
# Use xargs to handle potentially long lists of store paths
|
# Use xargs with parallel processing to copy store paths efficiently
|
||||||
# Equivalent to: xargs cp --recursive --target-directory
|
# --reflink=auto enables copy-on-write when filesystem supports it
|
||||||
# "$CLAN_TEST_STORE/nix/store" < "$closureInfo/store-paths"
|
# -P uses all available CPU cores for parallel copying
|
||||||
|
num_cpus = str(os.cpu_count() or 1)
|
||||||
with store_paths_file.open() as f:
|
with store_paths_file.open() as f:
|
||||||
subprocess.run( # noqa: S603
|
subprocess.run( # noqa: S603
|
||||||
[
|
[
|
||||||
XARGS_BIN,
|
XARGS_BIN,
|
||||||
XCP_BIN,
|
f"-P{num_cpus}", # Use all available CPUs
|
||||||
|
CP_BIN,
|
||||||
"--recursive",
|
"--recursive",
|
||||||
|
"--reflink=auto", # Use copy-on-write if available
|
||||||
"--target-directory",
|
"--target-directory",
|
||||||
f"{tmpdir}/store/nix/store",
|
f"{tmpdir}/store/nix/store",
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user