aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/servers/home-assistant/esphome.nix
blob: 2dc023df5a27f9c3063a121d0cb24fb71904b95b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{ lib, python3, platformio, esptool, git, protobuf3_10, fetchpatch }:

let
  python = python3.override {
    packageOverrides = self: super: {
      protobuf = super.protobuf.override {
        protobuf = protobuf3_10;
      };
      pyyaml = super.pyyaml.overridePythonAttrs (oldAttrs: rec {
        version = "5.1.2";
        src = oldAttrs.src.override {
          inherit version;
          sha256 = "1r5faspz73477hlbjgilw05xsms0glmsa371yqdd26znqsvg1b81";
        };
      });
    };
  };

in python.pkgs.buildPythonApplication rec {
  pname = "esphome";
  version = "1.14.3";

  src = python.pkgs.fetchPypi {
    inherit pname version;
    sha256 = "0xnsl000c5a2li9qw9anrzzq437qn1n4hcfc24i4rfq37awzmig7";
  };

  ESPHOME_USE_SUBPROCESS = "";

  propagatedBuildInputs = with python.pkgs; [
    voluptuous pyyaml paho-mqtt colorlog
    tornado protobuf tzlocal pyserial ifaddr
    protobuf
  ];

  # remove all version pinning (E.g tornado==5.1.1 -> tornado)
  postPatch = ''
    sed -i -e "s/==[0-9.]*//" setup.py
  '';

  makeWrapperArgs = [
    # platformio is used in esphomeyaml/platformio_api.py
    # esptool is used in esphomeyaml/__main__.py
    # git is used in esphomeyaml/writer.py
    "--prefix PATH : ${lib.makeBinPath [ platformio esptool git ]}"
    "--set ESPHOME_USE_SUBPROCESS ''"
  ];

  # Platformio will try to access the network
  # Instead, run the executable
  checkPhase = ''
    $out/bin/esphome --help > /dev/null
  '';

  meta = with lib; {
    description = "Make creating custom firmwares for ESP32/ESP8266 super easy";
    homepage = "https://esphome.io/";
    license = licenses.mit;
    maintainers = with maintainers; [ dotlambda globin ];
  };
}