diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 2d3960bf89b7d89c14cf5ea7acc35357fe7aa28d..ae78e65199223ad1660d2c5e23ee2df3f0f9780b 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -1718,7 +1718,7 @@ void DerivationGoal::startBuilder()
 
     /* In a sandbox, for determinism, always use the same temporary
        directory. */
-    tmpDirInSandbox = useChroot ? canonPath("/tmp/guix-build-", true) + drvName + "-0" : tmpDir;
+    tmpDirInSandbox = useChroot ? canonPath("/tmp", true) + "/guix-build-" + drvName + "-0" : tmpDir;
 
     /* For convenience, set an environment pointing to the top build
        directory. */