|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + fetchurl, |
| 5 | + ncurses6, |
| 6 | + libxcrypt-legacy, |
| 7 | + runtimeShell, |
| 8 | + zstd, |
| 9 | + xz, |
| 10 | +}: |
| 11 | + |
| 12 | +stdenv.mkDerivation rec { |
| 13 | + pname = "gcc-arm-embedded"; |
| 14 | + version = "14.2.rel1"; |
| 15 | + |
| 16 | + platform = |
| 17 | + { |
| 18 | + aarch64-darwin = "darwin-arm64"; |
| 19 | + aarch64-linux = "aarch64"; |
| 20 | + x86_64-darwin = "darwin-x86_64"; |
| 21 | + x86_64-linux = "x86_64"; |
| 22 | + } |
| 23 | + .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); |
| 24 | + |
| 25 | + src = fetchurl { |
| 26 | + url = "https://developer.arm.com/-/media/Files/downloads/gnu/${version}/binrel/arm-gnu-toolchain-${version}-${platform}-arm-none-eabi.tar.xz"; |
| 27 | + # hashes obtained from location ${url}.sha256asc |
| 28 | + sha256 = |
| 29 | + { |
| 30 | + aarch64-darwin = "c7c78ffab9bebfce91d99d3c24da6bf4b81c01e16cf551eb2ff9f25b9e0a3818"; |
| 31 | + aarch64-linux = "87330bab085dd8749d4ed0ad633674b9dc48b237b61069e3b481abd364d0a684"; |
| 32 | + x86_64-darwin = "2d9e717dd4f7751d18936ae1365d25916534105ebcb7583039eff1092b824505"; |
| 33 | + x86_64-linux = "62a63b981fe391a9cbad7ef51b17e49aeaa3e7b0d029b36ca1e9c3b2a9b78823"; |
| 34 | + } |
| 35 | + .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); |
| 36 | + }; |
| 37 | + |
| 38 | + dontConfigure = true; |
| 39 | + dontBuild = true; |
| 40 | + dontPatchELF = true; |
| 41 | + dontStrip = true; |
| 42 | + |
| 43 | + installPhase = '' |
| 44 | + mkdir -p $out |
| 45 | + cp -r * $out |
| 46 | + # these binaries require ancient Python 3.8 not available in Nixpkgs |
| 47 | + rm $out/bin/{arm-none-eabi-gdb-py,arm-none-eabi-gdb-add-index-py} || : |
| 48 | + ''; |
| 49 | + |
| 50 | + preFixup = lib.optionalString stdenv.isLinux '' |
| 51 | + find $out -type f | while read f; do |
| 52 | + patchelf "$f" > /dev/null 2>&1 || continue |
| 53 | + patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true |
| 54 | + patchelf --set-rpath ${ |
| 55 | + lib.makeLibraryPath [ |
| 56 | + "$out" |
| 57 | + stdenv.cc.cc |
| 58 | + ncurses6 |
| 59 | + libxcrypt-legacy |
| 60 | + zstd |
| 61 | + xz |
| 62 | + ] |
| 63 | + } "$f" || true |
| 64 | + done |
| 65 | + ''; |
| 66 | + |
| 67 | + meta = with lib; { |
| 68 | + description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors"; |
| 69 | + homepage = "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm"; |
| 70 | + license = with licenses; [ |
| 71 | + bsd2 |
| 72 | + gpl2 |
| 73 | + gpl3 |
| 74 | + lgpl21 |
| 75 | + lgpl3 |
| 76 | + mit |
| 77 | + ]; |
| 78 | + maintainers = with maintainers; [ |
| 79 | + prusnak |
| 80 | + prtzl |
| 81 | + ]; |
| 82 | + platforms = [ |
| 83 | + "x86_64-linux" |
| 84 | + "aarch64-linux" |
| 85 | + "x86_64-darwin" |
| 86 | + "aarch64-darwin" |
| 87 | + ]; |
| 88 | + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; |
| 89 | + }; |
| 90 | +} |
0 commit comments