diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index d65e56482d773a5dc3505e87ac98352588d5ec11..e73e4a4a33cb8ad5cf1ee1861ce834651823c352 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1909,6 +1909,7 @@ void DerivationGoal::startBuilder()
     builderOut.create();
 
     /* Fork a child to build the package. */
+#if CHROOT_ENABLED
     if (useChroot) {
         /* Set up private namespaces for the build:
 
@@ -1954,7 +1955,9 @@ void DerivationGoal::startBuilder()
         pid_t tmp;
         if (!string2Int<pid_t>(readLine(builderOut.readSide), tmp)) abort();
         pid = tmp;
-    } else {
+    } else
+#endif
+    {
         ProcessOptions options;
         options.allowVfork = !buildUser.enabled();
         pid = startProcess([&]() {