14 # Look up dependencies of specified components in component-packages.nix
15 , extraComponents ? [ ]
17 # Additional packages to add to propagatedBuildInputs
18 , extraPackages ? ps: []
20 # Override Python packages using
21 # self: super: { pkg = super.pkg.overridePythonAttrs (oldAttrs: { ... }); }
22 # Applied after defaultOverrides
23 , packageOverrides ? self: super: {}
25 # Skip pip install of required packages on startup
30 # Override the version of some packages pinned in Home Assistant's setup.py and requirements_all.txt
33 aioelectricitymaps = super.aioelectricitymaps.overridePythonAttrs (oldAttrs: rec {
35 src = fetchFromGitHub {
37 repo = "aioelectricitymaps";
38 rev = "refs/tags/v${version}";
39 hash = "sha256-q06B40c0uvSuzH/3YCoxg4p9aNIOPrphsoESktF+B14=";
41 nativeCheckInputs = with self; [
46 aiolyric = super.aiolyric.overridePythonAttrs (oldAttrs: rec {
48 src = fetchFromGitHub {
51 rev = "refs/tags/${version}";
52 hash = "sha256-FZhLjVrLzLv6CZz/ROlvbtBK9XnpO8pG48aSIoBxhCo=";
56 aiopurpleair = super.aiopurpleair.overridePythonAttrs (oldAttrs: rec {
57 version = "2022.12.1";
58 src = fetchFromGitHub {
60 repo = "aiopurpleair";
61 rev = "refs/tags/${version}";
62 hash = "sha256-YmJH4brWkTpgzyHwu9UnIWrY5qlDCmMtvF+KxQFXwfk=";
65 substituteInPlace pyproject.toml --replace-fail \
66 '"setuptools >= 35.0.2", "wheel >= 0.29.0", "poetry>=0.12"' \
71 aioskybell = super.aioskybell.overridePythonAttrs (oldAttrs: rec {
73 src = fetchFromGitHub {
76 rev = "refs/tags/${version}";
77 hash = "sha256-aBT1fDFtq1vasTvCnAXKV2vmZ6LBLZqRCiepv1HDJ+Q=";
81 aiowatttime = super.aiowatttime.overridePythonAttrs (oldAttrs: rec {
83 src = fetchFromGitHub {
86 rev = "refs/tags/${version}";
87 hash = "sha256-tWnxGLJT+CRFvkhxFamHxnLXBvoR8tfOvzH1o1i5JJg=";
90 substituteInPlace pyproject.toml --replace-fail \
91 '"setuptools >= 35.0.2", "wheel >= 0.29.0", "poetry>=0.12"' \
96 astral = super.astral.overridePythonAttrs (oldAttrs: rec {
100 inherit pname version;
101 hash = "sha256-5B2ZZ9XEi+QhNGVS8PTe2tQ/85qDV09f8q0ytmJ7b74=";
104 substituteInPlace pyproject.toml \
105 --replace-fail "poetry>=1.0.0b1" "poetry-core" \
106 --replace-fail "poetry.masonry" "poetry.core.masonry"
108 propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [
113 debugpy = super.debugpy.overridePythonAttrs (oldAttrs: {
114 # tests are deadlocking too often
115 # https://github.com/NixOS/nixpkgs/issues/262000
119 dsmr-parser = super.dsmr-parser.overridePythonAttrs (oldAttrs: rec {
121 src = fetchFromGitHub {
123 repo = "dsmr_parser";
124 rev = "refs/tags/v${version}";
125 hash = "sha256-PULrKRHrCuDFZcR+5ha0PjkN438QFgf2CrpYhKIqYTs=";
130 geojson = super.geojson.overridePythonAttrs (oldAttrs: rec {
132 src = fetchFromGitHub {
133 inherit (oldAttrs.src) owner repo;
134 rev = "refs/tags/${version}";
135 hash = "sha256-AcImffYki1gnIaZp/1eacNjdDgjn6qinPJXq9jYtoRg=";
140 gspread = super.gspread.overridePythonAttrs (oldAttrs: rec {
142 src = fetchFromGitHub {
145 rev = "refs/tags/v${version}";
146 hash = "sha256-i+QbnF0Y/kUMvt91Wzb8wseO/1rZn9xzeA5BWg1haks=";
148 dependencies = with self; [
153 intellifire4py = super.intellifire4py.overridePythonAttrs (oldAttrs: rec {
155 src = fetchFromGitHub {
157 repo = "intellifire4py";
158 rev = "refs/tags/${version}";
159 hash = "sha256-iqlKfpnETLqQwy5sNcK2x/TgmuN2hCfYoHEFK2WWVXI=";
161 nativeBuildInputs = with self; [
164 propagatedBuildInputs = with self; [
170 doCheck = false; # requires asynctest, which does not work on python 3.11
173 openhomedevice = super.openhomedevice.overridePythonAttrs (oldAttrs: rec {
175 src = fetchFromGitHub {
176 inherit (oldAttrs.src) owner repo;
177 rev = "refs/tags/${version}";
178 hash = "sha256-GGp7nKFH01m1KW6yMkKlAdd26bDi8JDWva6OQ0CWMIw=";
182 pymelcloud = super.pymelcloud.overridePythonAttrs (oldAttrs: {
184 src = fetchFromGitHub {
185 owner = "vilppuvuorinen";
187 rev = "33a827b6cd0b34f276790faa49bfd0994bb7c2e4"; # 2.5.x branch
188 sha256 = "sha256-Q3FIo9YJwtWPHfukEBjBANUQ1N1vr/DMnl1dgiN7vYg=";
192 notifications-android-tv = super.notifications-android-tv.overridePythonAttrs (oldAttrs: rec {
194 format = "setuptools";
196 src = fetchFromGitHub {
198 repo = "notifications_android_tv";
199 rev = "refs/tags/${version}";
200 hash = "sha256-adkcUuPl0jdJjkBINCTW4Kmc16C/HzL+jaRZB/Qr09A=";
203 nativeBuildInputs = with self; [
207 propagatedBuildInputs = with self; [
211 doCheck = false; # no tests
214 # Pinned due to API changes in 0.1.0
215 poolsense = super.poolsense.overridePythonAttrs (oldAttrs: rec {
220 hash = "sha256-17MHrYRmqkH+1QLtgq2d6zaRtqvb9ju9dvPt9gB2xCc=";
224 pyasn1 = super.pyasn1.overridePythonAttrs (oldAttrs: rec {
227 inherit (oldAttrs) pname;
229 hash = "sha256-rvd8n7lKOsWI6HhBIIvexGRHHZhxvVBQoofMmkdc0Lo=";
233 # Pinned due to API changes >0.3.5.3
234 pyatag = super.pyatag.overridePythonAttrs (oldAttrs: rec {
236 src = fetchFromGitHub {
240 sha256 = "00ly4injmgrj34p0lyx7cz2crgnfcijmzc0540gf7hpwha0marf6";
244 pyaussiebb = super.pyaussiebb.overridePythonAttrs (oldAttrs: rec {
246 src = fetchFromGitHub {
249 rev = "refs/tags/v${version}";
250 hash = "sha256-tEdddVsLFCHRvyLCctDakioiop2xWaJlfGE16P1ukHc=";
254 pydantic = super.pydantic_1;
256 pydexcom = super.pydexcom.overridePythonAttrs (oldAttrs: rec {
258 src = fetchFromGitHub {
261 rev = "refs/tags/${version}";
262 hash = "sha256-ItDGnUUUTwCz4ZJtFVlMYjjoBPn2h8QZgLzgnV2T/Qk=";
266 pytibber = super.pytibber.overridePythonAttrs (oldAttrs: rec {
268 src = fetchFromGitHub {
269 owner = "Danielhiversen";
271 rev = "refs/tags/${version}";
272 hash = "sha256-vi5f4V0nPb9K3nwdmwMDoNE85Or6haOWjMY4d/2Fj2s=";
274 dependencies = with self; [
283 pykaleidescape = super.pykaleidescape.overridePythonAttrs (oldAttrs: rec {
285 src = fetchFromGitHub {
286 inherit (oldAttrs.src) owner repo;
287 rev = "refs/tags/v${version}";
288 hash = "sha256-KM/gtpsQ27QZz2uI1t/yVN5no0zp9LZag1duAJzK55g=";
292 pyoctoprintapi = super.pyoctoprintapi.overridePythonAttrs (oldAttrs: rec {
294 src = fetchFromGitHub {
295 owner = "rfleming71";
296 repo = "pyoctoprintapi";
297 rev = "refs/tags/v${version}";
298 hash = "sha256-Jf/zYnBHVl3TYxFy9Chy6qNH/eCroZkmUOEWfd62RIo=";
302 pysnooz = super.pysnooz.overridePythonAttrs (oldAttrs: rec {
304 src = fetchFromGitHub {
305 owner = "AustinBrunkhorst";
307 rev = "refs/tags/v${version}";
308 hash = "sha256-hJwIObiuFEAVhgZXYB9VCeAlewBBnk0oMkP83MUCpyU=";
312 pytradfri = super.pytradfri.overridePythonAttrs (oldAttrs: rec {
314 src = fetchFromGitHub {
315 owner = "home-assistant-libs";
317 rev = "refs/tags/${version}";
318 hash = "sha256-xOdTzG0bF5p1QpkXv2btwrVugQRjSwdAj8bXcC0IoQg=";
322 # newer sigstore version transitivevly require pydantic>=2
323 sigstore = super.sigstore.overridePythonAttrs (oldAttrs: rec {
325 src = fetchFromGitHub {
327 repo = "sigstore-python";
328 rev = "refs/tags/v${version}";
329 hash = "sha256-QqY5GOBS75OkbSaF5Ua5jnJAhsYfVRuWLUoWDxX8Ino=";
331 dependencies = with self; [
340 sigstore-protobuf-specs
343 doCheck = false; # pytest too new
346 sigstore-protobuf-specs = super.sigstore-protobuf-specs.overridePythonAttrs {
349 pname = "sigstore-protobuf-specs";
351 hash = "sha256-YistIxYToo7T5mYKzYeBhnW06DSG9JoPDBmKxUdfy4E=";
353 nativeBuildInputs = with self; [
361 slack-sdk = super.slack-sdk.overridePythonAttrs (oldAttrs: rec {
363 src = fetchFromGitHub {
365 repo = "python-slackclient";
366 rev = "refs/tags/${version}";
367 hash = "sha256-U//HUe6e41wOOzoaDl4yXPnEASCzpGBIScHStWMN8tk=";
370 substituteInPlace setup.py \
371 --replace-fail "pytest-runner" ""
373 pythonImportsCheck = [ "slack" ];
374 doCheck = false; # Tests changed a lot for > 3
377 tuf = super.tuf.overridePythonAttrs rec {
379 src = fetchFromGitHub {
380 owner = "theupdateframework";
382 rev = "refs/tags/v${version}";
383 hash = "sha256-MdPctAZuKn/YAwpMJ5gWU7PXJD3iK7bYprLXV52wNQQ=";
390 versioningit = super.versioningit.overridePythonAttrs {
394 voluptuous = super.voluptuous.overridePythonAttrs (oldAttrs: rec {
396 src = fetchFromGitHub {
397 owner = "alecthomas";
399 rev = "refs/tags/${version}";
400 hash = "sha256-cz3Bd+/yPh+VOHxzi/W+gbDh/H5Nl/n4jvxDOirmAVk=";
404 # Pinned due to API changes ~1.0
405 vultr = super.vultr.overridePythonAttrs (oldAttrs: rec {
407 src = fetchFromGitHub {
408 owner = "spry-group";
409 repo = "python-vultr";
411 hash = "sha256-sHCZ8Csxs5rwg1ZG++hP3MfK7ldeAdqm5ta9tEXeW+I=";
415 xbox-webapi = super.xbox-webapi.overridePythonAttrs (oldAttrs: rec {
417 src = fetchFromGitHub {
419 repo = "xbox-webapi-python";
420 rev = "refs/tags/v${version}";
421 hash = "sha256-fzMB+I8+ZTJUiZovcuj+d5GdHY9BJyJd6j92EhJeIFI=";
424 sed -i '/pytest-runner/d' setup.py
426 propagatedBuildInputs = with self; [
433 nativeCheckInputs = with self; [
438 youtubeaio = super.youtubeaio.overridePythonAttrs (old: {
440 # fails with pydantic v1
441 "--deselect=tests/test_video.py::test_fetch_video"
445 # internal python packages only consumed by home-assistant itself
446 home-assistant-frontend = self.callPackage ./frontend.nix { };
447 home-assistant-intents = self.callPackage ./intents.nix { };
448 homeassistant = self.toPythonModule home-assistant;
449 pytest-homeassistant-custom-component = self.callPackage ./pytest-homeassistant-custom-component.nix { };
453 python = python312.override {
454 packageOverrides = lib.composeManyExtensions (defaultOverrides ++ [ packageOverrides ]);
457 componentPackages = import ./component-packages.nix;
459 availableComponents = builtins.attrNames componentPackages.components;
461 inherit (componentPackages) supportedComponentsWithTests;
463 getPackages = component: componentPackages.components.${component};
465 componentBuildInputs = lib.concatMap (component: getPackages component python.pkgs) extraComponents;
467 # Ensure that we are using a consistent package set
468 extraBuildInputs = extraPackages python.pkgs;
470 # Don't forget to run update-component-packages.py after updating
471 hassVersion = "2024.7.3";
473 in python.pkgs.buildPythonApplication rec {
474 pname = "homeassistant";
475 version = assert (componentPackages.version == hassVersion); hassVersion;
478 # check REQUIRED_PYTHON_VER in homeassistant/const.py
479 disabled = python.pythonOlder "3.11";
481 # don't try and fail to strip 6600+ python files, it takes minutes!
484 # Primary source is the git, which has the tests and allows bisecting the core
485 src = fetchFromGitHub {
486 owner = "home-assistant";
488 rev = "refs/tags/${version}";
489 hash = "sha256-6f4z1mpoLOntImC161+0CyyuT3NrPdfuCa6/+wqzHgs=";
492 # Secondary source is pypi sdist for translations
494 inherit pname version;
495 hash = "sha256-YtrOUSQFTgDFL+iPm3itkKsMXs9IKyB2rCnpe7Bn2Gk=";
498 build-system = with python.pkgs; [
520 # extract translations from pypi sdist
522 tar --extract --gzip --file $sdist --strip-components 1 --wildcards "**/translations"
525 # leave this in, so users don't have to constantly update their downstream patch handling
527 # Follow symlinks in /var/lib/hass/www
528 ./patches/static-follow-symlinks.patch
530 # Patch path to ffmpeg binary
532 src = ./patches/ffmpeg-path.patch;
533 ffmpeg = "${lib.getBin ffmpeg-headless}/bin/ffmpeg";
538 substituteInPlace tests/test_config.py --replace-fail '"/usr"' '"/build/media"'
540 substituteInPlace pyproject.toml --replace-fail "wheel~=0.43.0" wheel
542 sed -i 's/setuptools[~=]/setuptools>/' pyproject.toml
543 sed -i 's/wheel[~=]/wheel>/' pyproject.toml
546 dependencies = with python.pkgs; [
547 # Only packages required in pyproject.toml
551 aiohttp-fast-url-dispatcher
556 atomicwrites-homeassistant
565 home-assistant-bluetooth
574 psutil-home-assistant
588 # REQUIREMENTS in homeassistant/auth/mfa_modules/totp.py and homeassistant/auth/mfa_modules/notify.py
591 # Implicit dependency via homeassistant/requirements.py
595 makeWrapperArgs = lib.optional skipPip "--add-flags --skip-pip";
597 # upstream only tests on Linux, so do we.
598 doCheck = stdenv.isLinux;
600 nativeCheckInputs = with python.pkgs; [
601 # test infrastructure (selectively from requirement_test.txt)
617 # Sneakily imported in tests/conftest.py
619 # Used in tests/non_packaged_scripts/test_alexa_locales.py
621 ] ++ lib.concatMap (component: getPackages component python.pkgs) [
622 # some components are needed even if tests in tests/components are disabled
631 # assign tests grouped by file to workers
633 # retry racy tests that end in "RuntimeError: Event loop is closed"
635 "--only-rerun RuntimeError"
636 # enable full variable printing on error
638 # AssertionError: assert 1 == 0
639 "--deselect tests/test_config.py::test_merge"
640 # AssertionError: assert 6 == 5
641 "--deselect=tests/helpers/test_translation.py::test_caching"
642 # assert "Detected that integration 'hue' attempted to create an asyncio task from a thread at homeassistant/components/hue/light.py, line 23
643 "--deselect=tests/util/test_async.py::test_create_eager_task_from_thread_in_integration"
644 # Services were renamed to Actions in language strings, but the tests are lagging behind
645 "--deselect=tests/test_core.py::test_serviceregistry_service_that_not_exists"
646 "--deselect=tests/test_core.py::test_services_call_return_response_requires_blocking"
647 "--deselect=tests/test_core.py::test_serviceregistry_return_response_arguments"
648 "--deselect=tests/helpers/test_script.py::test_parallel_error"
649 "--deselect=tests/helpers/test_script.py::test_propagate_error_service_not_found"
650 "--deselect=tests/helpers/test_script.py::test_continue_on_error_automation_issue"
651 # tests are located in tests/
655 disabledTestPaths = [
656 # we neither run nor distribute hassfest
658 # we don't care about code quality
660 # don't bulk test all components
665 export HOME="$TEMPDIR"
667 # the tests require the existance of a media dir
670 # put ping binary into PATH, e.g. for wake_on_lan tests
671 export PATH=${inetutils}/bin:$PATH
680 supportedComponentsWithTests;
681 pythonPath = python.pkgs.makePythonPath (componentBuildInputs ++ extraBuildInputs);
682 frontend = python.pkgs.home-assistant-frontend;
683 intents = python.pkgs.home-assistant-intents;
685 nixos = nixosTests.home-assistant;
686 components = callPackage ./tests.nix { };
687 version = testers.testVersion {
688 package = home-assistant;
689 command = "hass --version";
691 withoutCheckDeps = home-assistant.overridePythonAttrs {
692 pname = "home-assistant-without-check-deps";
699 homepage = "https://home-assistant.io/";
700 description = "Open source home automation that puts local control and privacy first";
701 license = licenses.asl20;
702 maintainers = teams.home-assistant.members;
703 platforms = platforms.linux;
704 mainProgram = "hass";