From eb75c5942bd06289a4b91937e3b04d2d57660f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B7=F0=90=91=91=F0=90=91=B4=F0=90=91=95=F0=90=91=91?= =?UTF-8?q?=F0=90=91=A9=F0=90=91=A4?= Date: Tue, 30 Jun 2026 02:39:42 +0700 Subject: [PATCH 1/3] tools: remove all but python3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s infeasible to try to keep versions support up to date with Nixpkgs… this add a complicated patchelf script to the build, but for users, now they can just use latest python3, or easily override it. --- pkgs/esp-idf/tools.nix | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/pkgs/esp-idf/tools.nix b/pkgs/esp-idf/tools.nix index 80e665f..3724a2b 100644 --- a/pkgs/esp-idf/tools.nix +++ b/pkgs/esp-idf/tools.nix @@ -14,9 +14,6 @@ , glibc , ncurses5 , python3 -, python310 -, python311 -, python312 , libxml2_13 }: @@ -38,9 +35,6 @@ let libusb1 udev python3 - python310 - python311 - python312 libxml2_13 ]; @@ -101,15 +95,6 @@ let nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; buildInputs = lib.optionals stdenv.isLinux runtimeDeps; - # Configure autoPatchelfHook to ignore missing Python libraries that aren't available - autoPatchelfIgnoreMissingDeps = [ - "libpython3.13.so.1.0" - "libpython3.9.so.1.0" - "libpython3.8.so.1.0" - "libpython3.7.so.1.0" - "libpython3.6.so.1.0" - ]; - phases = [ "unpackPhase" "installPhase" ] ++ lib.optionals stdenv.isLinux [ "fixupPhase" ]; setSourceRoot = ''sourceRoot=$(echo ./${lib.strings.replicate stripContainerDirs "*/"})''; @@ -124,6 +109,10 @@ let dontStrip = true; installPhase = '' + python_lib="$(find "${lib.getLib python3}/lib" -maxdepth 1 -name 'libpython*.so.*' -type f | head -n1)" + so_name="$(patchelf --print-soname "$python_lib")" + export so_name + cp -r . $out rm $out/.attrs.* @@ -136,12 +125,16 @@ let bindir=unwrapped_bin fi if [ -d "$out/$bindir" ]; then - for file in $out/$bindir/*; do - if [ -f "$file" ] && [ -x "$file" ]; then - wrapper_file="$out/bin/$(basename "$file")" - [ -d "$out/bin" ] || mkdir -p "$out/bin" - makeWrapper "$file" "$wrapper_file" ${lib.strings.concatStringsSep " " exportVarsWrapperArgsList} + for file in $(find "$out/$bindir" -type f -executable -maxdepth 1); do + libpython_so=$(patchelf --print-needed "$file" | grep -e "^libpython" || true) + if [ -n "$libpython_so" ] && [ "$libpython_so" != "$so_name" ]; then + echo "Removing $file" >&2 + rm "$file" + continue fi + wrapper_file="$out/bin/$(basename "$file")" + [ -d "$out/bin" ] || mkdir -p "$out/bin" + makeWrapper "$file" "$wrapper_file" ${lib.strings.concatStringsSep " " exportVarsWrapperArgsList} done fi done From e58cd3b4cf58fa343ff0f3e8498f91562b68c874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B7=F0=90=91=91=F0=90=91=B4=F0=90=91=95=F0=90=91=91?= =?UTF-8?q?=F0=90=91=A9=F0=90=91=A4?= Date: Tue, 30 Jun 2026 02:59:37 +0700 Subject: [PATCH 2/3] tools: assert Python version requirement --- pkgs/esp-idf/tools.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/esp-idf/tools.nix b/pkgs/esp-idf/tools.nix index 3724a2b..d247713 100644 --- a/pkgs/esp-idf/tools.nix +++ b/pkgs/esp-idf/tools.nix @@ -17,6 +17,13 @@ , libxml2_13 }: +let + required-python-version = "3.9"; + ESP-IDF-version = lib.removePrefix "esp-idf-" versionSuffix; +in +assert lib.assertMsg (lib.versionAtLeast python3.version required-python-version) + "ESP-IDF ${ESP-IDF-version} requires Python ≧${required-python-version}"; + let # Map nix system strings to the platforms listed in tools.json systemToToolPlatformString = { From f425f0a43c59c0d82cc2ac3543aa9affc0cf3186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B7=F0=90=91=91=F0=90=91=B4=F0=90=91=95=F0=90=91=91?= =?UTF-8?q?=F0=90=91=A9=F0=90=91=A4?= Date: Tue, 30 Jun 2026 04:21:13 +0700 Subject: [PATCH 3/3] tools: use makeBinaryWrapper C binary has less overhead than a shell script --- pkgs/esp-idf/tools.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/esp-idf/tools.nix b/pkgs/esp-idf/tools.nix index d247713..d4d4fb3 100644 --- a/pkgs/esp-idf/tools.nix +++ b/pkgs/esp-idf/tools.nix @@ -4,7 +4,7 @@ , stdenv , lib , fetchurl -, makeWrapper +, makeBinaryWrapper , autoPatchelfHook # Dependencies for the various binary tools. @@ -99,7 +99,7 @@ let inherit url sha256; }; - nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; + nativeBuildInputs = [ makeBinaryWrapper ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; buildInputs = lib.optionals stdenv.isLinux runtimeDeps; phases = [ "unpackPhase" "installPhase" ] ++ lib.optionals stdenv.isLinux [ "fixupPhase" ]; @@ -141,7 +141,7 @@ let fi wrapper_file="$out/bin/$(basename "$file")" [ -d "$out/bin" ] || mkdir -p "$out/bin" - makeWrapper "$file" "$wrapper_file" ${lib.strings.concatStringsSep " " exportVarsWrapperArgsList} + makeBinaryWrapper "$file" "$wrapper_file" ${lib.strings.concatStringsSep " " exportVarsWrapperArgsList} done fi done