From bba51cb2479b7a23134f69b932811df999b892e1 Mon Sep 17 00:00:00 2001 From: phibkro <71797726+phibkro@users.noreply.github.com> Date: Fri, 5 Jun 2026 01:19:37 +0200 Subject: [PATCH] ollama: fix darwin build for 0.30.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two darwin-only issues surfaced when building on x86_64-darwin: 1. The conditional postPatch removed three test files (ml/backend/ggml/ggml_test.go, ml/nn/pooling/pooling_test.go, model/models/nemotronh/model_omni_test.go) that no longer exist in v0.30.5 upstream. The `rm` failed with "No such file or directory" and aborted patchPhase. Tests in the new paths (e.g. fs/ggml/ggml_test.go) pass on darwin without removal — verified via the test phase in this commit's local build. 2. preFixup ran `patchelf --shrink-rpath` unconditionally; patchelf is ELF-only and darwin's Mach-O dylibs don't carry the build-dir RPATH problem in the first place. Gated on stdenv.hostPlatform.isLinux. Verified: nix-build -A ollama on x86_64-darwin (macOS 15.6.1, Sequoia) lands /nix/store/.../ollama-0.30.5; checkPhase green for all listed packages including x/models/gemma4; ollama --version reports 0.30.5. Assisted-by: Claude Opus 4.7 --- pkgs/by-name/ol/ollama/package.nix | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/ol/ollama/package.nix b/pkgs/by-name/ol/ollama/package.nix index 3239f81dd1f9..dc4acb7722d8 100644 --- a/pkgs/by-name/ol/ollama/package.nix +++ b/pkgs/by-name/ol/ollama/package.nix @@ -230,12 +230,6 @@ goBuild (finalAttrs: { ( cd $TMPDIR/llama-cpp-src && \ cmake -DPATCH_DIR=$NIX_BUILD_TOP/source/llama/compat \ -P $NIX_BUILD_TOP/source/llama/compat/apply-patch.cmake ) - '' - # disable tests that fail in sandbox due to Metal init failure - + lib.optionalString stdenv.hostPlatform.isDarwin '' - rm ml/backend/ggml/ggml_test.go - rm ml/nn/pooling/pooling_test.go - rm model/models/nemotronh/model_omni_test.go ''; overrideModAttrs = _: _: { @@ -319,7 +313,9 @@ goBuild (finalAttrs: { # `.so` payloads end up with build-dir entries in RPATH. Drop them # before the forbidden-references check. $ORIGIN is preserved # unconditionally; only absolute /nix/store entries are kept. - preFixup = '' + # ELF-only (patchelf doesn't know Mach-O); darwin builds Mach-O dylibs + # that don't carry the build-dir RPATH problem in the first place. + preFixup = lib.optionalString stdenv.hostPlatform.isLinux '' find $out/lib/ollama -type f \( -name '*.so' -o -name '*.so.*' \) \ -exec patchelf --shrink-rpath --allowed-rpath-prefixes /nix/store {} + '';