Skip to content

Commit 5df1975

Browse files
authored
Merge pull request NixOS#12570 from P-E-Meunier/macos-fix
Fix macos sandbox issue
2 parents 0fa3edc + 300465c commit 5df1975

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libstore/unix/build/local-derivation-goal.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,18 @@ void LocalDerivationGoal::runChild()
22222222
without file-write* allowed, access() incorrectly returns EPERM
22232223
*/
22242224
sandboxProfile += "(allow file-read* file-write* process-exec\n";
2225+
2226+
// We create multiple allow lists, to avoid exceeding a limit in the darwin sandbox interpreter.
2227+
// See https://github.com/NixOS/nix/issues/4119
2228+
// We split our allow groups approximately at half the actual limit, 1 << 16
2229+
const int breakpoint = sandboxProfile.length() + (1 << 14);
22252230
for (auto & i : pathsInChroot) {
2231+
2232+
if (sandboxProfile.length() >= breakpoint) {
2233+
debug("Sandbox break: %d %d", sandboxProfile.length(), breakpoint);
2234+
sandboxProfile += ")\n(allow file-read* file-write* process-exec\n";
2235+
}
2236+
22262237
if (i.first != i.second.source)
22272238
throw Error(
22282239
"can't map '%1%' to '%2%': mismatched impure paths not supported on Darwin",

0 commit comments

Comments
 (0)