leanPackages.lean4: use nixpkgs cadical, patch all binaries

Lean binaries derive sysroot from IO.appPath; patch all of them
rather than just lean and lake. Add cadical to symlinkJoin paths
instead of bundling a copy via INSTALL_CADICAL.

https://github.com/NixOS/nixpkgs/pull/513024/changes/ed10debb3c8ad78e687521bb802383e21cd74472
This commit is contained in:
Nadja Yang
2026-06-04 16:48:52 -04:00
parent 6987e3afbe
commit cefae5621e
@@ -113,22 +113,18 @@ in
# Binary-patched for correct runtime discovery in wrapped environments.
symlinkJoin {
inherit (lean4) name pname;
paths = [ lean4 ];
paths = [
lean4
cadical
];
nativeBuildInputs = [ perl ];
postBuild = ''
newStorePath=$(echo "$out" | head -c 43)
# Copy (not symlink) IO.appPath resolves through symlinks.
rm $out/bin/lean $out/bin/lake
cp ${lean4}/bin/lean $out/bin/lean
cp ${lean4}/bin/lake $out/bin/lake
for bin in $out/bin/lean $out/bin/lake; do
cat "$bin" \
| perl -pe "s|\Q${oldStorePath}\E|$newStorePath|g" \
> "$bin.tmp"
chmod +x "$bin.tmp"
mv "$bin.tmp" "$bin"
for bin in ${lean4}/bin/*; do
test -f "$bin" || continue
install -m755 "$bin" "$out/bin/"
perl -pi -e "s|\Q${oldStorePath}\E|$newStorePath|g" "$out/bin/$(basename "$bin")"
done
'';