From ad97ee3676b4e0ef5df6cb2a81ce474f0671fdf8 Mon Sep 17 00:00:00 2001 From: Charles Duffy Date: Thu, 20 Jul 2023 14:52:46 -0500 Subject: [PATCH] Fix flake build on darwin `flake.nix` hardcodes `lib*.so`; however, `lib*.dylib` is correct on MacOS. Moreover, one needs to perform an rpath update to ensure that lib-directory libraries can be found at runtime. --- flake.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 5657e8258..04fc5db34 100644 --- a/flake.nix +++ b/flake.nix @@ -55,10 +55,22 @@ runHook preInstall install -D bin/* -t $out/bin - install -Dm644 lib*.so -t $out/lib mv $out/bin/main $out/bin/llama mv $out/bin/server $out/bin/llama-server + ${if pkgs.stdenv.isDarwin then '' + install -Dm644 lib*.dylib -t $out/lib + for f in $out/lib/*.dylib; do + install_name_tool -id "$f" "$f" + done + for f in "$out"/bin/*; do + [[ $(${pkgs.file}/bin/file "$f") = *Mach-O* ]] || continue + install_name_tool -add_rpath "$out/lib" "$f" + done + '' else '' + install -Dm644 lib*.so -t $out/lib + ''} + echo "#!${llama-python}/bin/python" > $out/bin/convert.py cat ${./convert.py} >> $out/bin/convert.py chmod +x $out/bin/convert.py