From 70d1dd0deb333227b65217b2d543bfd5f89ca823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 25 Aug 2025 13:18:18 +0200 Subject: [PATCH] nix_setup/cp: remove xcp again --- pkgs/testing/flake-module.nix | 4 ++-- pkgs/testing/nixos_test_lib/nix_setup.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/testing/flake-module.nix b/pkgs/testing/flake-module.nix index 3772259e9..848e68ea5 100644 --- a/pkgs/testing/flake-module.nix +++ b/pkgs/testing/flake-module.nix @@ -15,7 +15,7 @@ mkdir -p "$CLAN_TEST_STORE/nix/store" mkdir -p "$CLAN_TEST_STORE/nix/var/nix/gcroots" 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" fi ''; @@ -38,7 +38,7 @@ ]; postPatch = '' 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 '@xargs@' '${pkgs.findutils}/bin/xargs' ''; diff --git a/pkgs/testing/nixos_test_lib/nix_setup.py b/pkgs/testing/nixos_test_lib/nix_setup.py index e5fe50d9b..a93cba3f5 100644 --- a/pkgs/testing/nixos_test_lib/nix_setup.py +++ b/pkgs/testing/nixos_test_lib/nix_setup.py @@ -5,7 +5,7 @@ import subprocess from pathlib import Path # These paths will be substituted during package build -XCP_BIN = "@xcp@" +CP_BIN = "@cp@" NIX_STORE_BIN = "@nix-store@" 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(): store_paths_file = Path(closure_info) / "store-paths" if store_paths_file.exists(): - # Use xargs to handle potentially long lists of store paths - # Equivalent to: xargs cp --recursive --target-directory - # "$CLAN_TEST_STORE/nix/store" < "$closureInfo/store-paths" + # Use xargs with parallel processing to copy store paths efficiently + # --reflink=auto enables copy-on-write when filesystem supports it + # -P uses all available CPU cores for parallel copying + num_cpus = str(os.cpu_count() or 1) with store_paths_file.open() as f: subprocess.run( # noqa: S603 [ XARGS_BIN, - XCP_BIN, + f"-P{num_cpus}", # Use all available CPUs + CP_BIN, "--recursive", + "--reflink=auto", # Use copy-on-write if available "--target-directory", f"{tmpdir}/store/nix/store", ],