nixpkgs/pkgs/tools/misc/esphome/default.nix
Sandro Jäckel 588e5f80bf
esphome: remove reference to test inputs
nix store diff-closures:
python3.11-hypothesis: 6.91.0 → ∅, -4527.1 KiB
python3.11-iniconfig: 2.0.0 → ∅, -46.3 KiB
python3.11-installer: 0.7.0 → ∅, -1084.2 KiB
python3.11-mock: 5.1.0 → ∅, -401.9 KiB
python3.11-pytest: 7.4.3 → ∅, -4178.6 KiB
python3.11-pytest-asyncio: 0.21.1 → ∅, -97.3 KiB
python3.11-pytest-mock: 3.12.0 → ∅, -101.1 KiB
python3.11-wheel: 0.42.0 → ∅, -744.0 KiB
2024-02-07 01:11:36 +01:00

138 lines
3.5 KiB
Nix

{ lib
, callPackage
, python3Packages
, fetchFromGitHub
, installShellFiles
, platformio
, esptool
, git
, inetutils
, stdenv
}:
let
python = python3Packages.python.override {
packageOverrides = self: super: {
esphome-dashboard = self.callPackage ./dashboard.nix { };
};
};
in
python.pkgs.buildPythonApplication rec {
pname = "esphome";
version = "2023.12.9";
pyproject = true;
src = fetchFromGitHub {
owner = pname;
repo = pname;
rev = "refs/tags/${version}";
hash = "sha256-8SHf6cbPYPZctjJgIuEb7eOJVi5hWNONyRnMXK0iBXc=";
};
nativeBuildInputs = with python.pkgs; [
setuptools
argcomplete
installShellFiles
];
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
'';
# 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 python.pkgs; [
aioesphomeapi
argcomplete
click
colorama
cryptography
esphome-dashboard
kconfiglib
paho-mqtt
pillow
platformio
protobuf
pyparsing
pyserial
python-magic
pyyaml
requests
tornado
tzdata
tzlocal
voluptuous
];
makeWrapperArgs = [
# platformio is used in esphome/platformio_api.py
# esptool is used in esphome/__main__.py
# git is used in esphome/writer.py
# inetutils is used in esphome/dashboard/status/ping.py
"--prefix PATH : ${lib.makeBinPath [ platformio esptool git inetutils ]}"
"--prefix PYTHONPATH : ${python.pkgs.makePythonPath propagatedBuildInputs}" # will show better error messages
"--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}"
"--set ESPHOME_USE_SUBPROCESS ''"
];
# Needed for tests
__darwinAllowLocalNetworking = true;
nativeCheckInputs = with python3Packages; [
hypothesis
mock
pytest-asyncio
pytest-mock
pytestCheckHook
];
disabledTestPaths = [
# requires hypothesis 5.49, we have 6.x
# ImportError: cannot import name 'ip_addresses' from 'hypothesis.provisional'
"tests/unit_tests/test_core.py"
"tests/unit_tests/test_helpers.py"
];
postCheck = ''
$out/bin/esphome --help > /dev/null
'';
postInstall =
let
argcomplete = lib.getExe' python3Packages.argcomplete "register-python-argcomplete";
in
''
installShellCompletion --cmd esphome \
--bash <(${argcomplete} --shell bash esphome) \
--zsh <(${argcomplete} --shell zsh esphome) \
--fish <(${argcomplete} --shell fish esphome)
'';
passthru = {
dashboard = python.pkgs.esphome-dashboard;
updateScript = callPackage ./update.nix { };
};
meta = with lib; {
changelog = "https://github.com/esphome/esphome/releases/tag/${version}";
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 hexa ];
mainProgram = "esphome";
};
}