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