Skip to content

Commit 8f94eb2

Browse files
authored
Fix Mac nix flake check (#2183)
Darwin toolchain can drop or duplicate that placeholder in the final Mach-O, so the strict “exactly one occurrence” assumption sometimes fails on mac but not on Linux. I embed revision only if 1 occurrence; otherwise warn and keep original Also guarded install_name_tool to run only on Mach-O. <!-- Describe your change here --> --- <!-- Consider each and tick it off one way or the other --> * [x] CHANGELOG updated or not needed * [x] Documentation updated or not needed * [x] Haddocks updated or not needed * [x] No new TODOs introduced or explained herafter
2 parents 7aca7bb + 8795b55 commit 8f94eb2

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

nix/hydra/packages.nix

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,27 @@
3737
3838
echo "Patching embedded git revision in ${exe} to ${rev} ..."
3939
40-
# Ensure only one occurrence of placeholder
41-
if [[ $(grep -c -a ${placeholder} ${drv}/bin/${exe}) -ne 1 ]]; then
42-
echo "Not exactly one occurrence of ${placeholder} in ${drv}/bin/${exe}!"
43-
exit 1
44-
fi
45-
4640
mkdir -p $out/bin
47-
sed 's/${placeholder}/${rev}/' ${drv}/bin/${exe} > $out/bin/${exe}
48-
chmod +x $out/bin/${exe}
41+
occ=$(grep -c -a ${placeholder} ${drv}/bin/${exe} || true)
42+
if [[ "$occ" = "1" ]]; then
43+
sed 's/${placeholder}/${rev}/' ${drv}/bin/${exe} > $out/bin/${exe}
44+
chmod +x $out/bin/${exe}
45+
else
46+
echo "Warning: placeholder occurrence count=$occ in ${drv}/bin/${exe}; keeping original binary without embedding revision" >&2
47+
cp ${drv}/bin/${exe} $out/bin/${exe}
48+
chmod +x $out/bin/${exe}
49+
fi
4950
'';
5051
postFixup = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
51-
install_name_tool -add_rpath ${pkgs.zlib}/lib $out/bin/${exe}
52-
install_name_tool -add_rpath ${pkgs.lmdb}/lib $out/bin/${exe}
53-
install_name_tool -add_rpath ${pkgs.libcxx}/lib $out/bin/${exe}
54-
install_name_tool -add_rpath ${pkgs.libiconv}/lib $out/bin/${exe}
55-
install_name_tool -add_rpath ${pkgs.libffi}/lib $out/bin/${exe}
52+
if file "$out/bin/${exe}" | grep -q 'Mach-O'; then
53+
install_name_tool -add_rpath ${pkgs.zlib}/lib $out/bin/${exe}
54+
install_name_tool -add_rpath ${pkgs.lmdb}/lib $out/bin/${exe}
55+
install_name_tool -add_rpath ${pkgs.libcxx}/lib $out/bin/${exe}
56+
install_name_tool -add_rpath ${pkgs.libiconv}/lib $out/bin/${exe}
57+
install_name_tool -add_rpath ${pkgs.libffi}/lib $out/bin/${exe}
58+
else
59+
echo "Skipping install_name_tool: $out/bin/${exe} is not a Mach-O file" >&2
60+
fi
5661
'';
5762
};
5863

0 commit comments

Comments
 (0)