nix: fix installCheckPhase crashes on Darwin

Ensure that `OBJC_DISABLE_INITIALIZE_FORK_SAFETY=yes` is set when
starting the Nix daemon during tests, or the fetchurl.sh test will
crash trying to initialize libcurl. This is happening since IPv6 support
was enabled in https://github.com/NixOS/nixpkgs/pull/277471.

See also:
- http://sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html
- https://github.com/NixOS/nix/pull/2674
This commit is contained in:
Randy Eckenrode 2024-01-04 18:57:10 -05:00
parent f567c559e3
commit 8dd78e6dc9
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9

View File

@ -213,6 +213,11 @@ self = stdenv.mkDerivation {
preInstallCheck = lib.optionalString stdenv.isDarwin ''
export TMPDIR=$NIX_BUILD_TOP
''
# Prevent crashes in libcurl due to invoking Objective-C `+initialize` methods after `fork`.
# See http://sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html.
+ lib.optionalString stdenv.isDarwin ''
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=yes
''
# See https://github.com/NixOS/nix/issues/5687
+ lib.optionalString (atLeast25 && stdenv.isDarwin) ''
echo "exit 99" > tests/gc-non-blocking.sh