Error building some packages on Darwin with custom Nix location

I am running into an error building some packages on Darwin. My Nix install isn’t in the default /nix location, but somewhere else on the disk with a prefix of about 15 characters. The problem I am running into is that the path is too long for the install name tool. Here is the output from an attempt to build fluent-bit.

builder for '/custom/location/nix/store/55c5p8lhjv37q4l2fyqsrcd9d4wlyjhj-bootstrap-tools.drv' failed with exit code 1; last 10 log lines:
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libicucore.A.dylib
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libintl.8.dylib
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/liblzma.5.dylib
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libncursesw.6.dylib
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libpcre.1.dylib
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libpcreposix.0.dylib
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libresolv.9.dylib
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libssh2.1.dylib
  Patching /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libssl.1.1.dylib
  error: install_name_tool: changing install names or rpaths can't be redone for: /custom/location/nix/store/m5xnqnab72sa9vlxv16c6vm1lxlipz9m-bootstrap-tools/lib/libssl.1.1.dylib (for architecture x86_64) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)
cannot build derivation '/custom/location/nix/store/8ydvsk50wx4d7yq989ava45yq4d8j5xy-0001-enable-cross-compilation.patch.drv': 1 dependencies couldn't be built

It looks like it is in this loop when the error occurs: nixpkgs/make-bootstrap-tools.nix at 1c771276512249d8b704ec579a7161790c90ad22 · NixOS/nixpkgs · GitHub. This is happening in a company ci tool, so I can’t change the nix install location. Is there a way to set the -headerpad_max_install_names flag for install_name_tool in nix? I see install_name_tool in nix/store/<unique_string>-cctools-port. Would the change need to be in nixpkgs/pkgs/os-specific/darwin/cctools at master · NixOS/nixpkgs · GitHub?


1 Like

Yeah, running into the same issue.

21.05 worked
21.11 now has this issues in bootstrap
master does as well

This seems to be only on x86, not aarch64

It’s a bit of a long shot, but based on the history of the bootstrap tools with macOS, maybe @thefloweringash or @toonn might know where to start with this. I guess this issue really just impacts deployments that don’t install nix to /nix.

I have to admit this is beyond me. The main difference I can think of is we switched from Clang 7 to Clang 11 for the Darwin stdenv. Maybe you can try llvmPackages_7.stdenv to see whether that makes a difference?

As to the -headerpad and -headerpad_max_install_names options. AFAICT these should be passed to the linker not install_name_tool, maybe you can set LDFLAGS somewhere appropriately?