lol
1{ fetchFromGitHub, fetchurl, lib, python3Packages
2, coreVersion ? "1.13.3" # the version of the binary espurna image to flash
3, coreSize ? "1MB" # size of the binary image to flash
4, coreSha256 ? "0pkb2nmml0blrfiqpc46xpjc2dw927i89k1lfyqx827wanhc704x" }:
5
6with python3Packages;
7
8let
9 core = fetchurl {
10 url = "https://github.com/xoseperez/espurna/releases/download/${coreVersion}/espurna-${coreVersion}-espurna-core-${coreSize}.bin";
11 sha256 = coreSha256;
12 };
13
14in buildPythonApplication rec {
15 pname = "sonota-unstable";
16 version = "2018-10-07";
17
18 src = fetchFromGitHub {
19 owner = "mirko";
20 repo = "SonOTA";
21 rev = "d7f4b353858aae7ac403f95475a35560fb7ffeae";
22 sha256 = "0jd9xrhcyk8d2plbjnrlpn87536zr6n708797n0k5blf109q3c1z";
23 };
24
25 patches = [
26 ./set_resource_path.patch
27 ];
28
29 postPatch = ''
30 substituteInPlace sonota.py --subst-var out
31 '';
32
33 format = "other";
34
35 propagatedBuildInputs = [ httplib2 netifaces tornado ];
36
37 installPhase = ''
38 runHook preInstall
39
40 install -Dm755 sonota.py $out/bin/sonota
41 install -d $out/share/sonota
42 cp -r ssl static $out/share/sonota
43 cp ${core} $out/share/sonota/static/image_arduino.bin
44
45 runHook postInstall
46 '';
47
48 meta = with lib; {
49 description = "Flash Itead Sonoff devices with custom firmware via original OTA mechanism";
50 homepage = src.meta.homepage;
51 license = licenses.gpl2;
52 maintainers = with maintainers; [ peterhoeg ];
53 };
54}