2021-03-07 04:46:28 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2022-01-15 00:20:08 +00:00
|
|
|
, callPackage
|
2021-03-07 04:46:28 +00:00
|
|
|
, fetchFromGitHub
|
2021-12-11 19:59:08 +00:00
|
|
|
, fetchpatch
|
2021-03-07 04:46:28 +00:00
|
|
|
, python3
|
2021-12-11 19:59:08 +00:00
|
|
|
, substituteAll
|
|
|
|
, ffmpeg
|
2021-05-18 01:43:52 +01:00
|
|
|
, inetutils
|
2021-03-07 04:46:28 +00:00
|
|
|
, nixosTests
|
2018-07-29 20:49:46 +01:00
|
|
|
|
|
|
|
# Look up dependencies of specified components in component-packages.nix
|
2019-12-20 07:25:56 +00:00
|
|
|
, extraComponents ? [ ]
|
2018-07-29 20:49:46 +01:00
|
|
|
|
|
|
|
# Additional packages to add to propagatedBuildInputs
|
2018-01-14 21:26:52 +00:00
|
|
|
, extraPackages ? ps: []
|
2018-07-29 20:49:46 +01:00
|
|
|
|
2018-08-21 01:27:55 +01:00
|
|
|
# Override Python packages using
|
|
|
|
# self: super: { pkg = super.pkg.overridePythonAttrs (oldAttrs: { ... }); }
|
|
|
|
# Applied after defaultOverrides
|
2021-02-04 14:02:14 +00:00
|
|
|
, packageOverrides ? self: super: {}
|
2018-08-21 01:27:55 +01:00
|
|
|
|
2018-07-29 20:49:46 +01:00
|
|
|
# Skip pip install of required packages on startup
|
2018-01-14 21:26:52 +00:00
|
|
|
, skipPip ? true }:
|
|
|
|
|
|
|
|
let
|
2018-08-21 01:27:55 +01:00
|
|
|
defaultOverrides = [
|
2021-11-01 14:04:10 +00:00
|
|
|
# aiounify 29 breaks integration tests
|
|
|
|
(self: super: {
|
|
|
|
aiounifi = super.aiounifi.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "28";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Kane610";
|
|
|
|
repo = "aiounifi";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "1r86pk80sa1la2s7c6v9svh5cpkci6jcw1xziz0h09jdvv5j5iff";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2021-09-10 02:59:36 +01:00
|
|
|
# Override the version of some packages pinned in Home Assistant's setup.py and requirements_all.txt
|
|
|
|
(mkOverride "python-slugify" "4.0.1" "69a517766e00c1268e5bbfc0d010a0a8508de0b18d30ad5a1ff357f8ae724270")
|
|
|
|
|
2021-11-12 18:06:17 +00:00
|
|
|
(self: super: {
|
|
|
|
huawei-lte-api = super.huawei-lte-api.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "1.4.18";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Salamek";
|
|
|
|
repo = "huawei-lte-api";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "1qaqxmh03j10wa9wqbwgc5r3ays8wfr7bldvsm45fycr3qfyn5fg";
|
|
|
|
};
|
|
|
|
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ python3.pkgs.dicttoxml ];
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2021-03-21 03:14:48 +00:00
|
|
|
# Pinned due to API changes in iaqualink>=2.0, remove after
|
|
|
|
# https://github.com/home-assistant/core/pull/48137 was merged
|
|
|
|
(self: super: {
|
|
|
|
iaqualink = super.iaqualink.overridePythonAttrs (oldAttrs: rec {
|
2021-06-15 20:11:09 +01:00
|
|
|
version = "0.3.90";
|
2021-03-21 03:14:48 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "flz";
|
|
|
|
repo = "iaqualink-py";
|
2021-03-22 20:14:43 +00:00
|
|
|
rev = "v${version}";
|
2021-06-15 20:11:09 +01:00
|
|
|
sha256 = "0c8ckbbr1n8gx5k63ymgyfkbz3d0rbdvghg8fqdvbg4nrigrs5v0";
|
2021-03-21 03:14:48 +00:00
|
|
|
};
|
|
|
|
checkInputs = oldAttrs.checkInputs ++ [ python3.pkgs.asynctest ];
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2021-11-01 11:29:42 +00:00
|
|
|
# Pinned due to API changes in influxdb-client>1.21.0
|
|
|
|
(self: super: {
|
|
|
|
influxdb-client = super.influxdb-client.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "1.21.0";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "influxdata";
|
|
|
|
repo = "influxdb-client-python";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "081pwd3aa7kbgxqcl1hfi2ny4iapnxkcp9ypsfslr69d0khvfc4s";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2021-12-11 19:59:08 +00:00
|
|
|
(mkOverride "jinja2" "3.0.3" "1mvwr02s86zck5wsmd9wjxxb9iaqr17hdi5xza9vkwv8rmrv46v1")
|
2021-11-13 15:19:01 +00:00
|
|
|
|
2021-04-12 00:48:30 +01:00
|
|
|
# Pinned due to API changes in pyruckus>0.12
|
|
|
|
(self: super: {
|
|
|
|
pyruckus = super.pyruckus.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "0.12";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "gabe565";
|
|
|
|
repo = "pyruckus";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "0ykv6r6blbj3fg9fplk9i7xclkv5d93rwvx0fm5s8ms9f2s9ih8z";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2021-06-18 00:19:46 +01:00
|
|
|
# Pinned due to API changes in eebrightbox>=0.0.5
|
|
|
|
(self: super: {
|
|
|
|
eebrightbox = super.eebrightbox.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "0.0.4";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "krygal";
|
|
|
|
repo = "eebrightbox";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "0d8mmpwgrd7gymw5263r1v2wjv6dx6w6pq13d62fkfm4h2hya4a4";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2021-09-10 02:59:36 +01:00
|
|
|
# Pinned due to API changes in 0.1.0
|
|
|
|
(mkOverride "poolsense" "0.0.8" "09y4fq0gdvgkfsykpxnvmfv92dpbknnq5v82spz43ak6hjnhgcyp")
|
|
|
|
|
2022-01-11 12:46:41 +00:00
|
|
|
# Requirements for recorder not found: ['sqlalchemy==1.4.27'].
|
|
|
|
(mkOverride "sqlalchemy" "1.4.27" "031jbd0svrvwr3n52iibp9mkwsj9wicnck45yd26da5kmsfkas6p")
|
|
|
|
|
2021-12-11 19:59:08 +00:00
|
|
|
# Pinned due to API changes in 0.4.0
|
|
|
|
(self: super: {
|
|
|
|
vilfo-api-client = super.vilfo-api-client.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "0.3.3";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ManneW";
|
|
|
|
repo = "vilfo-api-client-python";
|
|
|
|
rev = "v$version}";
|
|
|
|
sha256 = "1gy5gpsg99rcm1cc3m30232za00r9i46sp74zpd12p3vzz1wyyqf";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
# Pinned due to API changes ~1.0
|
|
|
|
(self: super: {
|
|
|
|
vultr = super.vultr.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "0.1.2";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "spry-group";
|
|
|
|
repo = "python-vultr";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "1qjvvr2v9gfnwskdl0ayazpcmiyw9zlgnijnhgq9mcri5gq9jw5h";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2021-06-15 14:28:31 +01:00
|
|
|
# home-assistant-frontend does not exist in python3.pkgs
|
2018-08-21 01:27:55 +01:00
|
|
|
(self: super: {
|
2021-06-15 14:28:31 +01:00
|
|
|
home-assistant-frontend = self.callPackage ./frontend.nix { };
|
2018-08-21 01:27:55 +01:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
mkOverride = attrname: version: sha256:
|
|
|
|
self: super: {
|
|
|
|
${attrname} = super.${attrname}.overridePythonAttrs (oldAttrs: {
|
|
|
|
inherit version;
|
2018-05-11 18:39:37 +01:00
|
|
|
src = oldAttrs.src.override {
|
2018-08-21 01:27:55 +01:00
|
|
|
inherit version sha256;
|
2018-05-11 18:39:37 +01:00
|
|
|
};
|
|
|
|
});
|
2018-01-14 21:26:52 +00:00
|
|
|
};
|
2019-07-25 10:51:55 +01:00
|
|
|
|
2022-01-15 00:20:08 +00:00
|
|
|
python = python3.override {
|
2018-08-21 01:27:55 +01:00
|
|
|
# Put packageOverrides at the start so they are applied after defaultOverrides
|
|
|
|
packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) ([ packageOverrides ] ++ defaultOverrides);
|
2018-01-14 21:26:52 +00:00
|
|
|
};
|
|
|
|
|
2018-02-01 12:42:07 +00:00
|
|
|
componentPackages = import ./component-packages.nix;
|
|
|
|
|
|
|
|
availableComponents = builtins.attrNames componentPackages.components;
|
|
|
|
|
2022-01-15 00:20:08 +00:00
|
|
|
inherit (componentPackages) supportedComponentsWithTests;
|
2018-02-01 12:42:07 +00:00
|
|
|
|
2022-01-15 00:20:08 +00:00
|
|
|
getPackages = component: componentPackages.components.${component};
|
|
|
|
|
|
|
|
componentBuildInputs = lib.concatMap (component: getPackages component python.pkgs) extraComponents;
|
2018-02-01 12:42:07 +00:00
|
|
|
|
2018-01-14 21:26:52 +00:00
|
|
|
# Ensure that we are using a consistent package set
|
2022-01-15 00:20:08 +00:00
|
|
|
extraBuildInputs = extraPackages python.pkgs;
|
2018-01-14 21:26:52 +00:00
|
|
|
|
2018-02-01 12:42:07 +00:00
|
|
|
# Don't forget to run parse-requirements.py after updating
|
2022-01-18 07:59:52 +00:00
|
|
|
hassVersion = "2021.12.10";
|
2018-02-01 12:42:07 +00:00
|
|
|
|
2022-01-15 00:20:08 +00:00
|
|
|
in python.pkgs.buildPythonApplication rec {
|
2018-01-14 21:26:52 +00:00
|
|
|
pname = "homeassistant";
|
2018-02-01 12:42:07 +00:00
|
|
|
version = assert (componentPackages.version == hassVersion); hassVersion;
|
2018-01-14 21:26:52 +00:00
|
|
|
|
2020-10-07 19:28:25 +01:00
|
|
|
# check REQUIRED_PYTHON_VER in homeassistant/const.py
|
2022-01-15 00:20:08 +00:00
|
|
|
disabled = python.pythonOlder "3.8";
|
2020-02-26 15:51:25 +00:00
|
|
|
|
2021-01-06 23:20:39 +00:00
|
|
|
# don't try and fail to strip 6600+ python files, it takes minutes!
|
|
|
|
dontStrip = true;
|
|
|
|
|
2018-01-14 21:26:52 +00:00
|
|
|
# PyPI tarball is missing tests/ directory
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "home-assistant";
|
2020-05-20 22:41:42 +01:00
|
|
|
repo = "core";
|
2018-01-14 21:26:52 +00:00
|
|
|
rev = version;
|
2022-01-18 07:59:52 +00:00
|
|
|
hash = "sha256:0nyddcjy4diq5bakpb76frax44i0jraj2vvpfxrj50h9l5pdwsaf";
|
2018-01-14 21:26:52 +00:00
|
|
|
};
|
|
|
|
|
2020-11-04 11:52:54 +00:00
|
|
|
# leave this in, so users don't have to constantly update their downstream patch handling
|
2021-03-07 04:46:28 +00:00
|
|
|
patches = [
|
2021-12-11 19:59:08 +00:00
|
|
|
(substituteAll {
|
|
|
|
src = ./patches/ffmpeg-path.patch;
|
|
|
|
ffmpeg = "${lib.getBin ffmpeg}/bin/ffmpeg";
|
|
|
|
})
|
|
|
|
./patches/tests-ignore-OSErrors-in-hass-fixture.patch
|
2021-03-07 04:46:28 +00:00
|
|
|
];
|
2020-11-04 11:52:54 +00:00
|
|
|
|
2020-08-18 09:07:27 +01:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.py \
|
2021-12-11 19:59:08 +00:00
|
|
|
--replace "aiohttp==3.8.1" "aiohttp" \
|
|
|
|
--replace "async_timeout==4.0.0" "async_timeout" \
|
2021-04-07 19:34:08 +01:00
|
|
|
--replace "bcrypt==3.1.7" "bcrypt" \
|
2021-12-11 19:59:08 +00:00
|
|
|
--replace "cryptography==35.0.0" "cryptography" \
|
|
|
|
--replace "httpx==0.21.0" "httpx" \
|
2020-12-11 13:30:12 +00:00
|
|
|
--replace "pip>=8.0.3,<20.3" "pip" \
|
2022-01-03 22:15:52 +00:00
|
|
|
--replace "PyJWT==2.1.0" "PyJWT" \
|
2021-11-03 21:28:03 +00:00
|
|
|
--replace "pyyaml==6.0" "pyyaml" \
|
2021-11-26 11:22:38 +00:00
|
|
|
--replace "yarl==1.6.3" "yarl"
|
2020-10-07 19:28:25 +01:00
|
|
|
substituteInPlace tests/test_config.py --replace '"/usr"' '"/build/media"'
|
2020-08-18 09:07:27 +01:00
|
|
|
'';
|
|
|
|
|
2022-01-15 00:20:08 +00:00
|
|
|
propagatedBuildInputs = with python.pkgs; [
|
2021-06-15 20:16:08 +01:00
|
|
|
# Only packages required in setup.py
|
2021-02-04 16:36:21 +00:00
|
|
|
aiohttp
|
|
|
|
astral
|
|
|
|
async-timeout
|
2021-12-11 19:59:08 +00:00
|
|
|
atomicwrites
|
2021-02-04 16:36:21 +00:00
|
|
|
attrs
|
2021-02-05 13:48:53 +00:00
|
|
|
awesomeversion
|
2021-02-04 16:36:21 +00:00
|
|
|
bcrypt
|
|
|
|
certifi
|
|
|
|
ciso8601
|
|
|
|
cryptography
|
|
|
|
httpx
|
2021-12-28 15:43:50 +00:00
|
|
|
ifaddr
|
2021-02-04 16:36:21 +00:00
|
|
|
jinja2
|
|
|
|
pip
|
|
|
|
pyjwt
|
|
|
|
python-slugify
|
|
|
|
pytz
|
|
|
|
pyyaml
|
|
|
|
requests
|
2021-11-03 10:10:50 +00:00
|
|
|
ruamel-yaml
|
2021-02-04 16:36:21 +00:00
|
|
|
voluptuous
|
|
|
|
voluptuous-serialize
|
|
|
|
yarl
|
2021-06-27 17:38:36 +01:00
|
|
|
# Not in setup.py, but used in homeassistant/util/package.py
|
|
|
|
setuptools
|
2021-06-03 02:43:31 +01:00
|
|
|
] ++ lib.optionals (pythonOlder "3.9") [
|
|
|
|
backports-zoneinfo
|
2018-02-01 12:42:07 +00:00
|
|
|
] ++ componentBuildInputs ++ extraBuildInputs;
|
2018-01-14 21:26:52 +00:00
|
|
|
|
2021-02-06 03:47:04 +00:00
|
|
|
makeWrapperArgs = lib.optional skipPip "--add-flags --skip-pip";
|
|
|
|
|
2020-05-06 07:27:19 +01:00
|
|
|
# upstream only tests on Linux, so do we.
|
|
|
|
doCheck = stdenv.isLinux;
|
|
|
|
|
2022-01-15 00:20:08 +00:00
|
|
|
checkInputs = with python.pkgs; [
|
2021-05-10 20:25:43 +01:00
|
|
|
# test infrastructure (selectively from requirement_test.txt)
|
2021-11-03 21:28:03 +00:00
|
|
|
freezegun
|
2022-01-15 00:20:08 +00:00
|
|
|
jsonpickle
|
2021-02-04 16:36:21 +00:00
|
|
|
pytest-aiohttp
|
2021-11-03 21:28:03 +00:00
|
|
|
pytest-freezegun
|
2021-05-07 16:22:57 +01:00
|
|
|
pytest-mock
|
2021-03-02 16:56:33 +00:00
|
|
|
pytest-rerunfailures
|
2021-11-03 21:28:03 +00:00
|
|
|
pytest-socket
|
2021-02-04 16:36:21 +00:00
|
|
|
pytest-xdist
|
|
|
|
pytestCheckHook
|
|
|
|
requests-mock
|
2021-02-06 03:47:04 +00:00
|
|
|
respx
|
2022-01-15 00:20:08 +00:00
|
|
|
stdlib-list
|
|
|
|
tqdm
|
2021-05-10 20:25:43 +01:00
|
|
|
# required by tests/auth/mfa_modules
|
|
|
|
pyotp
|
2022-01-15 00:20:08 +00:00
|
|
|
] ++ lib.concatMap (component: getPackages component python.pkgs) [
|
|
|
|
# some components are needed even if tests in tests/components are disabled
|
2020-10-08 00:27:42 +01:00
|
|
|
"default_config"
|
2021-02-04 16:36:21 +00:00
|
|
|
"hue"
|
2020-10-08 00:27:42 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
pytestFlagsArray = [
|
2021-05-18 01:43:52 +01:00
|
|
|
# parallelize test run
|
2021-09-18 00:20:28 +01:00
|
|
|
"--numprocesses $NIX_BUILD_CORES"
|
2021-05-18 01:43:52 +01:00
|
|
|
# assign tests grouped by file to workers
|
|
|
|
"--dist loadfile"
|
2021-03-02 16:56:33 +00:00
|
|
|
# retry racy tests that end in "RuntimeError: Event loop is closed"
|
|
|
|
"--reruns 3"
|
|
|
|
"--only-rerun RuntimeError"
|
2021-05-15 15:56:35 +01:00
|
|
|
# enable full variable printing on error
|
|
|
|
"--showlocals"
|
2021-08-06 21:53:16 +01:00
|
|
|
# helpers/test_system_info.py: AssertionError: assert 'Unknown' == 'Home Assistant Container'
|
|
|
|
"--deselect tests/helpers/test_system_info.py::test_container_installationtype"
|
2021-05-18 01:43:52 +01:00
|
|
|
# tests are located in tests/
|
|
|
|
"tests"
|
2022-01-15 00:20:08 +00:00
|
|
|
];
|
2020-10-08 00:27:42 +01:00
|
|
|
|
2021-02-06 03:47:04 +00:00
|
|
|
disabledTestPaths = [
|
|
|
|
# don't bulk test all components
|
|
|
|
"tests/components"
|
|
|
|
# pyotp since v2.4.0 complains about the short mock keys, hass pins v2.3.0
|
|
|
|
"tests/auth/mfa_modules/test_notify.py"
|
|
|
|
];
|
|
|
|
|
2020-10-08 00:27:42 +01:00
|
|
|
disabledTests = [
|
2021-02-05 16:07:53 +00:00
|
|
|
# AssertionError: assert 1 == 0
|
|
|
|
"test_merge"
|
2022-01-14 00:17:59 +00:00
|
|
|
# Tests are flaky
|
|
|
|
"test_config_platform_valid"
|
2020-10-08 00:27:42 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
preCheck = ''
|
2021-04-07 19:34:08 +01:00
|
|
|
export HOME="$TEMPDIR"
|
|
|
|
|
2020-10-01 03:07:05 +01:00
|
|
|
# the tests require the existance of a media dir
|
|
|
|
mkdir /build/media
|
2021-04-07 00:41:57 +01:00
|
|
|
|
2021-05-18 01:43:52 +01:00
|
|
|
# put ping binary into PATH, e.g. for wake_on_lan tests
|
|
|
|
export PATH=${inetutils}/bin:$PATH
|
2018-01-14 21:26:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-05-06 07:39:44 +01:00
|
|
|
passthru = {
|
2022-01-15 00:20:08 +00:00
|
|
|
inherit
|
|
|
|
availableComponents
|
|
|
|
extraComponents
|
|
|
|
getPackages
|
|
|
|
python
|
|
|
|
supportedComponentsWithTests;
|
2020-06-20 11:05:30 +01:00
|
|
|
tests = {
|
2022-01-15 00:20:08 +00:00
|
|
|
nixos = nixosTests.home-assistant;
|
|
|
|
components = callPackage ./tests.nix { };
|
2020-06-20 11:05:30 +01:00
|
|
|
};
|
2020-05-06 07:39:44 +01:00
|
|
|
};
|
|
|
|
|
2018-02-10 22:19:19 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://home-assistant.io/";
|
2020-10-15 12:01:10 +01:00
|
|
|
description = "Open source home automation that puts local control and privacy first";
|
2018-01-14 21:26:52 +00:00
|
|
|
license = licenses.asl20;
|
2021-04-06 00:16:25 +01:00
|
|
|
maintainers = teams.home-assistant.members;
|
2021-04-03 22:39:33 +01:00
|
|
|
platforms = platforms.linux;
|
2018-01-14 21:26:52 +00:00
|
|
|
};
|
|
|
|
}
|