btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / es / esptool / package.nix
blob1a61e8ae351f7384c570427262abe366254a38e6
1 { lib
2 , fetchFromGitHub
3 , python3Packages
4 , softhsm
5 }:
7 python3Packages.buildPythonApplication rec {
8   pname = "esptool";
9   version = "4.8.1";
10   pyproject = true;
12   src = fetchFromGitHub {
13     owner = "espressif";
14     repo = "esptool";
15     rev = "refs/tags/v${version}";
16     hash = "sha256-cNEg2a3j7Vql06GwVaE9y86UtMkNsUdJYM00OEUra2w=";
17   };
19   postPatch = ''
20     patchShebangs ci
22     substituteInPlace test/test_espsecure_hsm.py \
23       --replace-fail "/usr/lib/softhsm" "${lib.getLib softhsm}/lib/softhsm"
24   '';
26   build-system = with python3Packages; [
27     setuptools
28   ];
30   dependencies = with python3Packages; [
31     argcomplete
32     bitstring
33     cryptography
34     ecdsa
35     intelhex
36     pyserial
37     reedsolo
38     pyyaml
39   ];
41   optional-dependencies = with python3Packages; {
42     hsm = [ python-pkcs11 ];
43   };
45   nativeCheckInputs = with python3Packages; [
46     pyelftools
47     pytestCheckHook
48     softhsm
49   ] ++ lib.flatten (lib.attrValues optional-dependencies);
51   # tests mentioned in `.github/workflows/test_esptool.yml`
52   checkPhase = ''
53     runHook preCheck
55     export SOFTHSM2_CONF=$(mktemp)
56     echo "directories.tokendir = $(mktemp -d)" > "$SOFTHSM2_CONF"
57     ./ci/setup_softhsm2.sh
59     pytest test/test_imagegen.py
60     pytest test/test_espsecure.py
61     pytest test/test_espsecure_hsm.py
62     pytest test/test_merge_bin.py
63     pytest test/test_image_info.py
64     pytest test/test_modules.py
66     runHook postCheck
67   '';
69   meta = with lib; {
70     changelog = "https://github.com/espressif/esptool/blob/${src.rev}/CHANGELOG.md";
71     description = "ESP8266 and ESP32 serial bootloader utility";
72     homepage = "https://github.com/espressif/esptool";
73     license = licenses.gpl2Plus;
74     maintainers = with maintainers; [ dezgeg dotlambda ] ++ teams.lumiguide.members;
75     platforms = with platforms; linux ++ darwin;
76     mainProgram = "esptool.py";
77   };