66 libxcrypt-legacy ,
77 xz ,
88 zstd ,
9+ makeBinaryWrapper ,
10+ darwin ,
911} :
1012
1113stdenv . mkDerivation rec {
@@ -34,6 +36,11 @@ stdenv.mkDerivation rec {
3436 . ${ stdenv . hostPlatform . system } or ( throw "Unsupported system: ${ stdenv . hostPlatform . system } " ) ;
3537 } ;
3638
39+ nativeBuildInputs = lib . optionals ( stdenv . isDarwin && stdenv . isx86_64 ) [
40+ makeBinaryWrapper
41+ darwin . sigtool
42+ ] ;
43+
3744 patches = [
3845 # fix double entry in share/info/porting.info
3946 # https://github.com/NixOS/nixpkgs/issues/363902
@@ -52,22 +59,34 @@ stdenv.mkDerivation rec {
5259 rm $out/bin/{arm-none-eabi-gdb-py,arm-none-eabi-gdb-add-index-py} || :
5360 '' ;
5461
55- preFixup = lib . optionalString stdenv . isLinux ''
56- find $out -type f | while read f; do
57- patchelf "$f" > /dev/null 2>&1 || continue
58- patchelf --set-interpreter $(cat ${ stdenv . cc } /nix-support/dynamic-linker) "$f" || true
59- patchelf --set-rpath ${
60- lib . makeLibraryPath [
61- "$out"
62- stdenv . cc . cc
63- ncurses6
64- libxcrypt-legacy
65- xz
66- zstd
67- ]
68- } "$f" || true
69- done
70- '' ;
62+ preFixup =
63+ lib . optionalString stdenv . isLinux ''
64+ find $out -type f | while read f; do
65+ patchelf "$f" > /dev/null 2>&1 || continue
66+ patchelf --set-interpreter $(cat ${ stdenv . cc } /nix-support/dynamic-linker) "$f" || true
67+ patchelf --set-rpath ${
68+ lib . makeLibraryPath [
69+ "$out"
70+ stdenv . cc . cc
71+ ncurses6
72+ libxcrypt-legacy
73+ xz
74+ zstd
75+ ]
76+ } "$f" || true
77+ done
78+ ''
79+ + lib . optionalString ( stdenv . isDarwin && stdenv . isx86_64 ) ''
80+ find "$out" -executable -type f | while read executable; do
81+ ( \
82+ install_name_tool \
83+ -change "/usr/local/opt/zstd/lib/libzstd.1.dylib" "${ lib . getLib zstd } /lib/libzstd.1.dylib" \
84+ -change "/usr/local/opt/xz/lib/liblzma.5.dylib" "${ lib . getLib xz } /lib/liblzma.5.dylib" \
85+ "$executable" \
86+ && codesign -f -s - "$executable" \
87+ ) || true
88+ done
89+ '' ;
7190
7291 meta = with lib ; {
7392 description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors" ;
0 commit comments