@@ -1,36 +1,60 @@
1−{ lib, python3, platformio, esptool, git, protobuf3_12, fetchpatch }:
2−
3−let
4− python = python3.override {
5− packageOverrides = self: super: {
6− protobuf = super.protobuf.override {
7− protobuf = protobuf3_12;
8− };
9− };
10− };
1+{ lib
2+, python3
3+, fetchFromGitHub
4+, platformio
5+, esptool
6+, git
7+}:
118
12−in python.pkgs.buildPythonApplication rec {
9+python3.pkgs.buildPythonApplication rec {
1310 pname = "esphome";
14− version = "1.16.0";
11+ version = "1.17.1";
1512
16− src = python.pkgs.fetchPypi {
17− inherit pname version;
18− sha256 = "0pvwzkdcpjqdf7lh1k3xv1la5v60lhjixzykapl7f2xh71fbm144";
13+ src = fetchFromGitHub {
14+ owner = pname;
15+ repo = pname;
16+ rev = "v${version}";
17+ sha256 = "0483glwi155ca1wnffwhmwn17d7kwk4hjwmckb8zs197rfqmb55v";
1918 };
2019
21− ESPHOME_USE_SUBPROCESS = "";
22−
23− propagatedBuildInputs = with python.pkgs; [
24− voluptuous pyyaml paho-mqtt colorlog colorama
25− tornado protobuf tzlocal pyserial ifaddr
26− protobuf click
27− ];
28−
29− # remove all version pinning (E.g tornado==5.1.1 -> tornado)
3020 postPatch = ''
21+ # remove all version pinning (E.g tornado==5.1.1 -> tornado)
3122 sed -i -e "s/==[0-9.]*//" requirements.txt
23+
24+ # drop coverage testing
25+ sed -i '/--cov/d' pytest.ini
26+
27+ # migrate use of hypothesis internals to be compatible with hypothesis>=5.32.1
28+ # https://github.com/esphome/issues/issues/2021
29+ substituteInPlace tests/unit_tests/strategies.py --replace \
30+ "@st.defines_strategy_with_reusable_values" \
31+ "@st.defines_strategy(force_reusable_values=True)"
3232 '';
3333
34+ # Remove esptool and platformio from requirements
35+ ESPHOME_USE_SUBPROCESS = "";
36+
37+ # esphome has optional dependencies it does not declare, they are
38+ # loaded when certain config blocks are used, like `font`, `image`
39+ # or `animation`.
40+ # They have validation functions like:
41+ # - validate_cryptography_installed
42+ # - validate_pillow_installed
43+ propagatedBuildInputs = with python3.pkgs; [
44+ click
45+ colorama
46+ cryptography
47+ ifaddr
48+ paho-mqtt
49+ pillow
50+ protobuf
51+ pyserial
52+ pyyaml
53+ tornado
54+ tzlocal
55+ voluptuous
56+ ];
57+
3458 makeWrapperArgs = [
3559 # platformio is used in esphomeyaml/platformio_api.py
3660 # esptool is used in esphomeyaml/__main__.py
@@ -39,16 +63,24 @@ in python.pkgs.buildPythonApplication rec {
3963 "--set ESPHOME_USE_SUBPROCESS ''"
4064 ];
4165
42− # Platformio will try to access the network
43− # Instead, run the executable
44− checkPhase = ''
66+ checkInputs = with python3.pkgs; [
67+ hypothesis
68+ mock
69+ pytest-mock
70+ pytestCheckHook
71+ ];
72+
73+ postCheck = ''
4574 $out/bin/esphome --help > /dev/null
4675 '';
4776
4877 meta = with lib; {
4978 description = "Make creating custom firmwares for ESP32/ESP8266 super easy";
5079 homepage = "https://esphome.io/";
51− license = licenses.mit;
80+ license = with licenses; [
81+ mit # The C++/runtime codebase of the ESPHome project (file extensions .c, .cpp, .h, .hpp, .tcc, .ino)
82+ gpl3Only # The python codebase and all other parts of this codebase
83+ ];
5284 maintainers = with maintainers; [ globin elseym hexa ];
5385 };
5486}