builder: exclude namespace mounts from Cargo clean

This commit is contained in:
2026-11-07 12:55:28 +00:00
parent 2f18f0fa4c
commit 0be19f3f9c
+4 -2
View File
@@ -95,13 +95,15 @@ impl Builder {
// Cargo clean must remove its directory, not a namespace mount point.
let target_mount = base.join("target");
let target = target_mount.join("cargo");
// Keep /tmp's namespace mountpoints outside the directory Cargo clean removes.
let temporary = target_mount.join("tmp");
let registry = base.join("cargo");
let cache = base.join("kache");
if source.exists() {
std::fs::remove_dir_all(&source)?;
}
let before = files::copy_out(self.root.as_ref(), &workspace, &source).await?;
for path in [&target, &registry, &cache, &target.join("tmp")] {
for path in [&target, &registry, &cache, &temporary] {
std::fs::create_dir_all(path)?;
}
std::fs::write(
@@ -187,7 +189,7 @@ impl Builder {
"/nix/store",
])
.arg("--bind")
.arg(target.join("tmp"))
.arg(&temporary)
.arg("/tmp")
.arg("--ro-bind")
.arg(executable("sh")?)