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.
This commit is contained in:
Charles Duffy 2023-07-20 14:52:46 -05:00
parent e782c9e735
commit ad97ee3676
No known key found for this signature in database
GPG key ID: F5852B6FA75D7BB2

View file

@ -55,10 +55,22 @@
runHook preInstall runHook preInstall
install -D bin/* -t $out/bin install -D bin/* -t $out/bin
install -Dm644 lib*.so -t $out/lib
mv $out/bin/main $out/bin/llama mv $out/bin/main $out/bin/llama
mv $out/bin/server $out/bin/llama-server 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 echo "#!${llama-python}/bin/python" > $out/bin/convert.py
cat ${./convert.py} >> $out/bin/convert.py cat ${./convert.py} >> $out/bin/convert.py
chmod +x $out/bin/convert.py chmod +x $out/bin/convert.py