From 07a431c62f30da45b92df914489dd9497c05402e Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 22 Nov 2024 20:12:46 +0400 Subject: [PATCH 1/3] bun: fix hanging build on x86_64-darwin This commit disables generating shell completions on x86_64-darwin because Bun now requires AVX support to run, which is not available in the version of Rosetta on our builders. The baseline builds of bun now also require AVX support, making them a non-option. --- pkgs/by-name/bu/bun/package.nix | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/pkgs/by-name/bu/bun/package.nix b/pkgs/by-name/bu/bun/package.nix index d9eddfe394a8..8975db4fabbc 100644 --- a/pkgs/by-name/bu/bun/package.nix +++ b/pkgs/by-name/bu/bun/package.nix @@ -33,19 +33,30 @@ stdenvNoCC.mkDerivation rec { runHook postInstall ''; - postPhases = lib.optionals (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) [ "postPatchelf" ]; - postPatchelf = '' - completions_dir=$(mktemp -d) - SHELL="bash" $out/bin/bun completions $completions_dir - SHELL="zsh" $out/bin/bun completions $completions_dir - SHELL="fish" $out/bin/bun completions $completions_dir + # We currently cannot generate completions for x86_64-darwin because bun requires avx support to run, which is: + # 1. Not currently supported by the version of Rosetta on our aarch64 builders + # 2. Is not correctly detected even on macOS 15+, where it is available through Rosetta + # + # The baseline builds are no longer an option because they too now require avx support. + postInstall = + lib.optionalString + ( + stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform + && !(stdenvNoCC.hostPlatform.isDarwin && stdenvNoCC.hostPlatform.isx86_64) + ) + '' + completions_dir=$(mktemp -d) - installShellCompletion --name bun \ - --bash $completions_dir/bun.completion.bash \ - --zsh $completions_dir/_bun \ - --fish $completions_dir/bun.fish - ''; + SHELL="bash" $out/bin/bun completions $completions_dir + SHELL="zsh" $out/bin/bun completions $completions_dir + SHELL="fish" $out/bin/bun completions $completions_dir + + installShellCompletion --name bun \ + --bash $completions_dir/bun.completion.bash \ + --zsh $completions_dir/_bun \ + --fish $completions_dir/bun.fish + ''; passthru = { sources = { From 25bd3f09719570e02c33f834a4e71f7a102b9d01 Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 22 Nov 2024 20:17:46 +0400 Subject: [PATCH 2/3] bun: fix missing symbol crash on macOS 12 Adds `darwin.ICU` to the library path. Fixes the following error: > dyld[69576]: Symbol not found: _ubrk_clone > Referenced from: /nix/store/zz94xy01809rlwp70hakg5ws10acma3v-bun-1.1.36/bin/bun > Expected in: /usr/lib/libicucore.A.dylib --- pkgs/by-name/bu/bun/package.nix | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/bu/bun/package.nix b/pkgs/by-name/bu/bun/package.nix index 8975db4fabbc..e3bb543c8d3d 100644 --- a/pkgs/by-name/bu/bun/package.nix +++ b/pkgs/by-name/bu/bun/package.nix @@ -4,11 +4,13 @@ , autoPatchelfHook , unzip , installShellFiles +, makeWrapper , openssl , writeShellScript , curl , jq , common-updater-scripts +, darwin }: stdenvNoCC.mkDerivation rec { @@ -18,7 +20,7 @@ stdenvNoCC.mkDerivation rec { src = passthru.sources.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}"); strictDeps = true; - nativeBuildInputs = [ unzip installShellFiles ] ++ lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ]; + nativeBuildInputs = [ unzip installShellFiles makeWrapper ] ++ lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ]; buildInputs = [ openssl ]; dontConfigure = true; @@ -33,14 +35,17 @@ stdenvNoCC.mkDerivation rec { runHook postInstall ''; - - # We currently cannot generate completions for x86_64-darwin because bun requires avx support to run, which is: - # 1. Not currently supported by the version of Rosetta on our aarch64 builders - # 2. Is not correctly detected even on macOS 15+, where it is available through Rosetta - # - # The baseline builds are no longer an option because they too now require avx support. postInstall = - lib.optionalString + lib.optionalString stdenvNoCC.hostPlatform.isDarwin '' + wrapProgram $out/bin/bun \ + --prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [ darwin.ICU ]} + '' + # We currently cannot generate completions for x86_64-darwin because bun requires avx support to run, which is: + # 1. Not currently supported by the version of Rosetta on our aarch64 builders + # 2. Is not correctly detected even on macOS 15+, where it is available through Rosetta + # + # The baseline builds are no longer an option because they too now require avx support. + + lib.optionalString ( stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform && !(stdenvNoCC.hostPlatform.isDarwin && stdenvNoCC.hostPlatform.isx86_64) From a5d52b7a45dfa3a1ef20b5edfd5c92a1f7fbfc33 Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 22 Nov 2024 17:21:57 +0000 Subject: [PATCH 3/3] bun: run post hooks after patchelf --- pkgs/by-name/bu/bun/package.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/bu/bun/package.nix b/pkgs/by-name/bu/bun/package.nix index e3bb543c8d3d..eb5b74d6a9e3 100644 --- a/pkgs/by-name/bu/bun/package.nix +++ b/pkgs/by-name/bu/bun/package.nix @@ -35,7 +35,8 @@ stdenvNoCC.mkDerivation rec { runHook postInstall ''; - postInstall = + postPhases = [ "postPatchelf"]; + postPatchelf = lib.optionalString stdenvNoCC.hostPlatform.isDarwin '' wrapProgram $out/bin/bun \ --prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [ darwin.ICU ]}