06d92ba195
We store esphome in the nix store, which results in its file permissions being 0444. Esphome, when compiling a firmware image, will copy these files from the nix store to a working directory. When updating between versions it will notice these files changed and try to copy the new version over, which would break, because the user had no write permissions on the files. ❯ esphome compile 01e4ac.yml INFO Reading configuration 01e4ac.yml... INFO Detected timezone 'CET' with UTC offset 1 and daylight saving time from 27 March 02:00:00 to 30 October 03:00:00 INFO Generating C++ source... ERROR Error copying file /nix/store/lmzrgl1arqfd98jcss4rsmmy6dbffddn-esphome-1.19.2/lib/python3.8/site-packages/esphome/components/api/api_connection.cpp to 01e4ac/src/esphome/components/api/api_connection.cpp: [Errno 13] Permission denied: '01e4ac/src/esphome/components/api/api_connection.cpp' To fix this we modify chmod to 0644 just before esphome tries a copy operation, which will fix permissions on existing working directories just in time.
102 lines
2.5 KiB
Nix
102 lines
2.5 KiB
Nix
{ lib
|
|
, pkgs
|
|
, python3
|
|
, fetchFromGitHub
|
|
, platformio
|
|
, esptool
|
|
, git
|
|
}:
|
|
|
|
let
|
|
esphome-dashboard = pkgs.callPackage ./dashboard.nix {};
|
|
in
|
|
python3.pkgs.buildPythonApplication rec {
|
|
pname = "esphome";
|
|
version = "1.19.2";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = pname;
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "0bz6gkrvn7mwmjsqrazgpy9r64m5jj462v0izgvdymkx8bjd8mpi";
|
|
};
|
|
|
|
patches = [
|
|
# fix missing write permissions on src files before modifing them
|
|
./fix-src-permissions.patch
|
|
];
|
|
|
|
postPatch = ''
|
|
# remove all version pinning (E.g tornado==5.1.1 -> tornado)
|
|
sed -i -e "s/==[0-9.]*//" requirements.txt
|
|
|
|
# drop coverage testing
|
|
sed -i '/--cov/d' pytest.ini
|
|
|
|
# migrate use of hypothesis internals to be compatible with hypothesis>=5.32.1
|
|
# https://github.com/esphome/issues/issues/2021
|
|
substituteInPlace tests/unit_tests/strategies.py --replace \
|
|
"@st.defines_strategy_with_reusable_values" \
|
|
"@st.defines_strategy(force_reusable_values=True)"
|
|
'';
|
|
|
|
# Remove esptool and platformio from requirements
|
|
ESPHOME_USE_SUBPROCESS = "";
|
|
|
|
# esphome has optional dependencies it does not declare, they are
|
|
# loaded when certain config blocks are used, like `font`, `image`
|
|
# or `animation`.
|
|
# They have validation functions like:
|
|
# - validate_cryptography_installed
|
|
# - validate_pillow_installed
|
|
propagatedBuildInputs = with python3.pkgs; [
|
|
click
|
|
colorama
|
|
cryptography
|
|
esphome-dashboard
|
|
ifaddr
|
|
paho-mqtt
|
|
pillow
|
|
protobuf
|
|
pyserial
|
|
pyyaml
|
|
tornado
|
|
tzlocal
|
|
voluptuous
|
|
];
|
|
|
|
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 ''"
|
|
];
|
|
|
|
checkInputs = with python3.pkgs; [
|
|
hypothesis
|
|
mock
|
|
pytest-asyncio
|
|
pytest-mock
|
|
pytest-sugar
|
|
pytestCheckHook
|
|
];
|
|
|
|
postCheck = ''
|
|
$out/bin/esphome --help > /dev/null
|
|
'';
|
|
|
|
passthru = {
|
|
dashboard = esphome-dashboard;
|
|
};
|
|
|
|
meta = with lib; {
|
|
description = "Make creating custom firmwares for ESP32/ESP8266 super easy";
|
|
homepage = "https://esphome.io/";
|
|
license = with licenses; [
|
|
mit # The C++/runtime codebase of the ESPHome project (file extensions .c, .cpp, .h, .hpp, .tcc, .ino)
|
|
gpl3Only # The python codebase and all other parts of this codebase
|
|
];
|
|
maintainers = with maintainers; [ globin elseym hexa ];
|
|
};
|
|
}
|