{ pkgs ? import { }, }: let host-triple = "x86_64-unknown-linux-gnu"; gcc-arch = "xtensa-esp-elf"; gcc-release = "16.1.0_20260609"; toolchain-pkg = pkgs.stdenv.mkDerivation rec { pname = "esp32-xtensa-rust-toolchain"; version = "1.97.0.0"; srcs = [ (pkgs.fetchurl { url = "https://github.com/esp-rs/rust-build/releases/download/v${version}/rust-${version}-${host-triple}.tar.xz"; hash = "sha256-qZv+5pIh6f9thjiPaBHuaIzUBeagQAo80XhOjUY+nZk="; }) (pkgs.fetchurl { url = let gcc-file = "${gcc-arch}-${gcc-release}-x86_64-linux-gnu.tar.xz"; in "https://github.com/espressif/crosstool-NG/releases/download/esp-${gcc-release}/${gcc-file}"; hash = "sha256-9wh1Lrs1yrIfGEsldBFO0Rh2GdsO24pLqRPAbKL6Z14="; }) (pkgs.fetchurl { url = "https://github.com/esp-rs/rust-build/releases/download/v${version}/rust-src-${version}.tar.xz"; hash = "sha256-Vo1oi5+PMy7E0EZXVE+tI+mc4R6ebPWDWXnmiijGi3M="; }) # TODO maybe I need clang but so far it works without https://github.com/esp-rs/espup/blob/main/src/toolchain/llvm.rs ]; sourceRoot = "."; nativeBuildInputs = [ pkgs.autoPatchelfHook ]; buildInputs = [ pkgs.zlib pkgs.stdenv.cc.cc.lib ]; installPhase = '' runHook preInstall patchShebangs --build rust-nightly-x86_64-unknown-linux-gnu/install.sh rust-src-nightly/install.sh rust-nightly-x86_64-unknown-linux-gnu/install.sh --destdir="$out" --prefix="" --without=rust-docs-json-preview,rust-docs --disable-ldconfig rust-src-nightly/install.sh --destdir="$out" --prefix="" --disable-ldconfig cp -pr --reflink=auto -- xtensa-esp-elf "$out"; # ensure linker is in PATH ln -s $out/xtensa-esp-elf/bin/* "$out/bin/" runHook postInstall ''; }; in (pkgs.mkShell { packages = with pkgs; [ espflash toolchain-pkg ]; })