nixosTestLib: substitute dependencies on tools in

This commit is contained in:
Jörg Thalheim
2025-07-02 16:26:23 +02:00
parent c509f333e4
commit a53efb9386
2 changed files with 11 additions and 2 deletions

View File

@@ -37,6 +37,11 @@
setuptools
wheel
];
postPatch = ''
substituteInPlace nixos_test_lib/nix_setup.py \
--replace '@cp@' '${pkgs.coreutils}/bin/cp' \
--replace '@nix-store@' '${pkgs.nix}/bin/nix-store'
'';
doCheck = false;
};

View File

@@ -4,6 +4,10 @@ import os
import subprocess
from pathlib import Path
# These paths will be substituted during package build
CP_BIN = "@cp@"
NIX_STORE_BIN = "@nix-store@"
def setup_nix_in_nix(closure_info: str | None) -> None:
"""Set up Nix store inside test environment
@@ -44,7 +48,7 @@ def setup_nix_in_nix(closure_info: str | None) -> None:
# Copy store paths to test store using external cp command
# (handles symlinks better)
subprocess.run(
["cp", "--recursive", "--target", f"{tmpdir}/store"]
[CP_BIN, "--recursive", "--target", f"{tmpdir}/store"]
+ [path.strip() for path in store_paths if path.strip()],
check=True,
)
@@ -57,7 +61,7 @@ def setup_nix_in_nix(closure_info: str | None) -> None:
with registration_file.open() as f:
subprocess.run(
["nix-store", "--load-db"],
[NIX_STORE_BIN, "--load-db"],
input=f.read(),
text=True,
env=env,