7 # Look up dependencies of specified components in component-packages.nix
8 , extraComponents ? [ ]
10 # Additional packages to add to propagatedBuildInputs
11 , extraPackages ? ps: []
13 # Override Python packages using
14 # self: super: { pkg = super.pkg.overridePythonAttrs (oldAttrs: { ... }); }
15 # Applied after defaultOverrides
16 , packageOverrides ? self: super: {}
18 # Skip pip install of required packages on startup
23 # Override the version of some packages pinned in Home Assistant's setup.py
25 # Pinned due to API changes in astral>=2.0, required by the sun/moon plugins
26 # https://github.com/home-assistant/core/issues/36636
27 (mkOverride "astral" "1.10.1"
28 "d2a67243c4503131c856cafb1b1276de52a86e5b8a1d507b7e08bee51cb67bf1")
30 # Pinned due to API changes in iaqualink>=2.0, remove after
31 # https://github.com/home-assistant/core/pull/48137 was merged
33 iaqualink = super.iaqualink.overridePythonAttrs (oldAttrs: rec {
35 src = fetchFromGitHub {
37 repo = "iaqualink-py";
39 sha256 = "16mn6nd9x3hm6j6da99qhwbqs95hh8wx21r1h1m9csl76z77n9lh";
41 checkInputs = oldAttrs.checkInputs ++ [ python3.pkgs.asynctest ];
45 # Pinned due to API changes in pylilterbot>=2021.3.0
47 pylitterbot = super.pylitterbot.overridePythonAttrs (oldAttrs: rec {
49 src = fetchFromGitHub {
50 owner = "natekspencer";
53 sha256 = "142lhijm51v11cd0lhcfdnjdd143jxi2hjsrqdq0rrbbnmj6mymp";
55 # had no tests before 2021.3.0
60 # Pinned due to bug in ring-doorbell 0.7.0
61 # https://github.com/tchellomello/python-ring-doorbell/issues/240
62 (mkOverride "ring-doorbell" "0.6.2"
63 "fbd537722a27b3b854c26506d894b7399bb8dc57ff36083285971227a2d46560")
65 # Pinned due to API changes in pyruckus>0.12
67 pyruckus = super.pyruckus.overridePythonAttrs (oldAttrs: rec {
69 src = fetchFromGitHub {
73 sha256 = "0ykv6r6blbj3fg9fplk9i7xclkv5d93rwvx0fm5s8ms9f2s9ih8z";
78 # hass-frontend does not exist in python3.pkgs
80 hass-frontend = self.callPackage ./frontend.nix { };
84 mkOverride = attrname: version: sha256:
86 ${attrname} = super.${attrname}.overridePythonAttrs (oldAttrs: {
88 src = oldAttrs.src.override {
89 inherit version sha256;
94 py = python3.override {
95 # Put packageOverrides at the start so they are applied after defaultOverrides
96 packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) ([ packageOverrides ] ++ defaultOverrides);
99 componentPackages = import ./component-packages.nix;
101 availableComponents = builtins.attrNames componentPackages.components;
103 getPackages = component: builtins.getAttr component componentPackages.components;
105 componentBuildInputs = lib.concatMap (component: getPackages component py.pkgs) extraComponents;
107 # Ensure that we are using a consistent package set
108 extraBuildInputs = extraPackages py.pkgs;
110 # Don't forget to run parse-requirements.py after updating
111 hassVersion = "2021.4.4";
113 in with py.pkgs; buildPythonApplication rec {
114 pname = "homeassistant";
115 version = assert (componentPackages.version == hassVersion); hassVersion;
117 # check REQUIRED_PYTHON_VER in homeassistant/const.py
118 disabled = pythonOlder "3.8";
120 # don't try and fail to strip 6600+ python files, it takes minutes!
123 inherit availableComponents;
125 # PyPI tarball is missing tests/ directory
126 src = fetchFromGitHub {
127 owner = "home-assistant";
130 sha256 = "1p36ymjhirl32ax3xxdg9ia089jw1klww5imq18r6ksajafr78ys";
133 # leave this in, so users don't have to constantly update their downstream patch handling
138 substituteInPlace setup.py \
139 --replace "awesomeversion==21.2.3" "awesomeversion" \
140 --replace "bcrypt==3.1.7" "bcrypt" \
141 --replace "cryptography==3.3.2" "cryptography" \
142 --replace "pip>=8.0.3,<20.3" "pip" \
143 --replace "pytz>=2021.1" "pytz" \
144 --replace "pyyaml==5.4.1" "pyyaml" \
145 --replace "ruamel.yaml==0.15.100" "ruamel.yaml"
146 substituteInPlace tests/test_config.py --replace '"/usr"' '"/build/media"'
149 propagatedBuildInputs = [
150 # Only packages required in setup.py + hass-frontend
173 ] ++ componentBuildInputs ++ extraBuildInputs;
175 makeWrapperArgs = lib.optional skipPip "--add-flags --skip-pip";
177 # upstream only tests on Linux, so do we.
178 doCheck = stdenv.isLinux;
181 # test infrastructure
188 # component dependencies
191 ] ++ lib.concatMap (component: getPackages component py.pkgs) componentTests;
193 # We can reasonably test components that don't communicate with any network
194 # services. Before adding new components to this list make sure we have all
195 # its dependencies packaged and listed in ./component-packages.nix.
225 "device_sun_light_trigger"
227 "devolo_home_control"
244 "fritzbox_callmonitor"
312 "persistent_notification"
323 "rituals_perfume_genie"
384 # limit amout of runners to reduce race conditions
386 # retry racy tests that end in "RuntimeError: Event loop is closed"
388 "--only-rerun RuntimeError"
389 # assign tests grouped by file to workers
391 # tests are located in tests/
393 # screenlogic/test_config_flow.py: Tries to send out UDP broadcasts
394 "--deselect tests/components/screenlogic/test_config_flow.py::test_form_cannot_connect"
395 # dynamically add packages required for component tests
396 ] ++ map (component: "tests/components/" + component) componentTests;
398 disabledTestPaths = [
399 # don't bulk test all components
401 # pyotp since v2.4.0 complains about the short mock keys, hass pins v2.3.0
402 "tests/auth/mfa_modules/test_notify.py"
406 # AssertionError: assert 1 == 0
407 "test_error_posted_as_event"
409 # ModuleNotFoundError: No module named 'pyqwikswitch'
410 "test_merge_id_schema"
411 # keyring.errors.NoKeyringError: No recommended backend was available.
412 "test_secrets_from_unrelated_fails"
413 "test_secrets_credstash"
414 # generic/test_camera.py: AssertionError: 500 == 200
415 "test_fetching_without_verify_ssl"
416 "test_fetching_url_with_verify_ssl"
417 # util/test_package.py: AssertionError on package.is_installed('homeassistant>=999.999.999')
418 "test_check_package_version_does_not_match"
422 export HOME="$TEMPDIR"
424 # the tests require the existance of a media dir
427 # error out when component test directory is missing, otherwise hidden by xdist execution :(
428 for component in ${lib.concatStringsSep " " (map lib.escapeShellArg componentTests)}; do
429 test -d "tests/components/$component" || {
430 >2& echo "ERROR: Tests for component '$component' were enabled, but they do not exist!"
437 inherit (py.pkgs) hass-frontend;
439 inherit (nixosTests) home-assistant;
444 homepage = "https://home-assistant.io/";
445 description = "Open source home automation that puts local control and privacy first";
446 license = licenses.asl20;
447 maintainers = teams.home-assistant.members;
448 platforms = platforms.linux;