1{ lib
2, fetchFromGitHub
3, python3
4, softhsm
5}:
6
7python3.pkgs.buildPythonApplication rec {
8 pname = "esptool";
9 version = "4.7.0";
10
11 format = "setuptools";
12
13 src = fetchFromGitHub {
14 owner = "espressif";
15 repo = "esptool";
16 rev = "v${version}";
17 hash = "sha256-yrEwCg0e+8jZorL6jcqeuKUCFoV0oP9HVFh1n/ezjPg=";
18 };
19
20 postPatch = ''
21 patchShebangs ci
22
23 substituteInPlace test/test_espsecure_hsm.py \
24 --replace "/usr/lib/softhsm" "${lib.getLib softhsm}/lib/softhsm"
25 '';
26
27 propagatedBuildInputs = with python3.pkgs; [
28 bitstring
29 cryptography
30 ecdsa
31 intelhex
32 pyserial
33 reedsolo
34 pyyaml
35 python-pkcs11
36 ];
37
38 nativeCheckInputs = with python3.pkgs; [
39 pyelftools
40 pytestCheckHook
41 softhsm
42 ];
43
44 # tests mentioned in `.github/workflows/test_esptool.yml`
45 checkPhase = ''
46 runHook preCheck
47
48 export SOFTHSM2_CONF=$(mktemp)
49 echo "directories.tokendir = $(mktemp -d)" > "$SOFTHSM2_CONF"
50 ./ci/setup_softhsm2.sh
51
52 pytest test/test_imagegen.py
53 pytest test/test_espsecure.py
54 pytest test/test_espsecure_hsm.py
55 pytest test/test_merge_bin.py
56 pytest test/test_image_info.py
57 pytest test/test_modules.py
58
59 runHook postCheck
60 '';
61
62 meta = with lib; {
63 description = "ESP8266 and ESP32 serial bootloader utility";
64 homepage = "https://github.com/espressif/esptool";
65 license = licenses.gpl2Plus;
66 maintainers = with maintainers; [ dezgeg dotlambda ] ++ teams.lumiguide.members;
67 platforms = with platforms; linux ++ darwin;
68 mainProgram = "esptool.py";
69 };
70}