Skip to content

Commit 8705feb

Browse files
authored
Merge pull request NixOS#12686 from NixOS/mergify/bp/2.27-maintenance/pr-12570
Fix macos sandbox issue (backport NixOS#12570)
2 parents bdaa8c5 + aecd2b5 commit 8705feb

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
@@ -2144,7 +2144,18 @@ void LocalDerivationGoal::runChild()
21442144
without file-write* allowed, access() incorrectly returns EPERM
21452145
*/
21462146
sandboxProfile += "(allow file-read* file-write* process-exec\n";
2147+
2148+
// We create multiple allow lists, to avoid exceeding a limit in the darwin sandbox interpreter.
2149+
// See https://github.com/NixOS/nix/issues/4119
2150+
// We split our allow groups approximately at half the actual limit, 1 << 16
2151+
const int breakpoint = sandboxProfile.length() + (1 << 14);
21472152
for (auto & i : pathsInChroot) {
2153+
2154+
if (sandboxProfile.length() >= breakpoint) {
2155+
debug("Sandbox break: %d %d", sandboxProfile.length(), breakpoint);
2156+
sandboxProfile += ")\n(allow file-read* file-write* process-exec\n";
2157+
}
2158+
21482159
if (i.first != i.second.source)
21492160
throw Error(
21502161
"can't map '%1%' to '%2%': mismatched impure paths not supported on Darwin",

0 commit comments

Comments
 (0)