Describe the bug
Nix 2.34.4 on macOS causes patch: **** out of memory errors during patchPhase for packages that apply diffs (e.g. gz-transport14, freeimage, libdart). The patches themselves are valid and apply successfully outside the Nix build environment.
https://github.com/devbrom/gazebo-sim-overlay/tree/darwin-support
The issue does not occur on Nix 2.31.2 with an identical system configuration, same macOS version, same flake, and same nixpkgs pin.
Nix 2.34.x appears to result in nixbld build users running with a stack size soft limit of 8176 KB, which is insufficient for patch to process multi-chunk diffs. Running sudo -u _nixbld1 ulimit -s confirms this value.
Steps To Reproduce
- Install Nix 2.34.4 on macOS (arm64, darwin25)
- Run
nix develop github:devbrom/gazebo-sim-overlay/darwin-support#default -c $SHELL
- Observe
patch: **** out of memory during patchPhase
- Confirm the patch applies successfully outside the sandbox:
- Confirm nixbld stack limit:
sudo -u _nixbld1 ulimit -s # returns 8176
- Downgrade to Nix 2.31.2 - builds succeed without any other changes
Expected behavior
nixbld build users should have sufficient stack size to run standard POSIX tools like patch. The stack limit applied to build processes should not regress between Nix versions on macOS.
Metadata
nix (Nix) 2.34.4
nix (Nix) 2.31.2 # works
nix log /nix/store/m6bsabwxy7ylr1rw79425fhabb9pr36k-gz-transport14-14.1.0.drv
Running phase: qtPreHook
@nix { "action": "setPhase", "phase": "qtPreHook" }
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/4kynmimn3yfdr358r77a1ik067w83dgg-gz-transport14_14.1.0-source
source root is gz-transport14_14.1.0-source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
applying patch /nix/store/d281scad7p61mqdiw87zfpc6x4dczg4f-cmd.patch
patch: **** out of memory
Additional context
sandbox = false does not resolve the issue - the stack limit is applied at the nixbld process level, not the sandbox
- Raising the nix-daemon's launchd
SoftResourceLimits.Stack also does not resolve it - the limit applies to child nixbld processes, not the daemon itself
- The only working fixes are: downgrade to 2.31.2
- Patches as small as 4 lines fail, ruling out patch file size as the cause - the issue is purely the stack constraint on the build user
Checklist
Add 👍 to issues you find important.
Describe the bug
Nix 2.34.4 on macOS causes patch:
**** out of memoryerrors duringpatchPhasefor packages that apply diffs (e.g. gz-transport14, freeimage, libdart). The patches themselves are valid and apply successfully outside the Nix build environment.https://github.com/devbrom/gazebo-sim-overlay/tree/darwin-support
The issue does not occur on Nix 2.31.2 with an identical system configuration, same macOS version, same flake, and same nixpkgs pin.
Nix 2.34.x appears to result in nixbld build users running with a stack size soft limit of
8176 KB, which is insufficient forpatchto process multi-chunk diffs. Runningsudo -u _nixbld1 ulimit -sconfirms this value.Steps To Reproduce
nix develop github:devbrom/gazebo-sim-overlay/darwin-support#default -c $SHELLpatch: **** out of memoryduring patchPhasesudo -u _nixbld1 ulimit -s # returns 8176Expected behavior
nixbld build users should have sufficient stack size to run standard POSIX tools like patch. The stack limit applied to build processes should not regress between Nix versions on macOS.
Metadata
Additional context
sandbox = falsedoes not resolve the issue - the stack limit is applied at the nixbld process level, not the sandboxSoftResourceLimits.Stackalso does not resolve it - the limit applies to child nixbld processes, not the daemon itselfChecklist
Add 👍 to issues you find important.