2021-03-09 03:18:52 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2022-01-19 23:45:15 +00:00
|
|
|
, callPackage
|
2021-03-09 03:18:52 +00:00
|
|
|
, fetchFromGitHub
|
2021-12-19 01:06:50 +00:00
|
|
|
, fetchpatch
|
2021-03-09 03:18:52 +00:00
|
|
|
, python3
|
2021-12-19 01:06:50 +00:00
|
|
|
, substituteAll
|
|
|
|
, ffmpeg
|
2021-05-20 23:08:51 +00:00
|
|
|
, inetutils
|
2021-03-09 03:18:52 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Look up dependencies of specified components in component-packages.nix
|
|
|
|
, extraComponents ? [ ]
|
|
|
|
|
|
|
|
# Additional packages to add to propagatedBuildInputs
|
|
|
|
, extraPackages ? ps: []
|
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
# Write out info about included extraComponents and extraPackages
|
|
|
|
, writeText
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Override Python packages using
|
|
|
|
# self: super: { pkg = super.pkg.overridePythonAttrs (oldAttrs: { ... }); }
|
|
|
|
# Applied after defaultOverrides
|
2021-02-19 19:06:45 +00:00
|
|
|
, packageOverrides ? self: super: {}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Skip pip install of required packages on startup
|
|
|
|
, skipPip ? true }:
|
|
|
|
|
|
|
|
let
|
|
|
|
defaultOverrides = [
|
2021-09-18 10:52:07 +00:00
|
|
|
# Override the version of some packages pinned in Home Assistant's setup.py and requirements_all.txt
|
2022-03-05 16:20:37 +00:00
|
|
|
(mkOverride "python-slugify" "4.0.1" "sha256-aaUXdm4AwSaOW7/A0BCgqFCN4LGNMK1aH/NX+K5yQnA=")
|
2022-04-03 18:54:34 +00:00
|
|
|
(mkOverride "voluptuous" "0.12.2" "sha256-TbGsUHnbkkmCDUnIkctGYKb4yuNQSRIQq850H6v1ZRM=")
|
2022-03-05 16:20:37 +00:00
|
|
|
|
|
|
|
# pytest-aiohttp>0.3.0 breaks home-assistant tests
|
|
|
|
(self: super: {
|
|
|
|
pytest-aiohttp = super.pytest-aiohttp.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "0.3.0";
|
|
|
|
src = oldAttrs.src.override {
|
|
|
|
inherit version;
|
2022-03-30 09:31:56 +00:00
|
|
|
hash = "sha256-ySmFQzljeXc3WDhwO2L+9jUoWYvAqdRRY566lfSqpE8=";
|
2022-03-05 16:20:37 +00:00
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
propagatedBuildInputs = with python3.pkgs; [ aiohttp pytest ];
|
|
|
|
doCheck = false;
|
|
|
|
patches = [];
|
2022-03-05 16:20:37 +00:00
|
|
|
});
|
|
|
|
aiohomekit = super.aiohomekit.overridePythonAttrs (oldAttrs: {
|
|
|
|
doCheck = false; # requires aiohttp>=1.0.0
|
|
|
|
});
|
|
|
|
hass-nabucasa = super.hass-nabucasa.overridePythonAttrs (oldAttrs: {
|
|
|
|
doCheck = false; # requires aiohttp>=1.0.0
|
|
|
|
});
|
2022-03-30 09:31:56 +00:00
|
|
|
snitun = super.snitun.overridePythonAttrs (oldAttrs: {
|
|
|
|
doCheck = false; # requires aiohttp>=1.0.0
|
|
|
|
});
|
2022-03-05 16:20:37 +00:00
|
|
|
zwave-js-server-python = super.zwave-js-server-python.overridePythonAttrs (oldAttrs: {
|
|
|
|
doCheck = false; # requires aiohttp>=1.0.0
|
|
|
|
});
|
|
|
|
})
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
(self: super: {
|
2021-12-06 16:07:01 +00:00
|
|
|
huawei-lte-api = super.huawei-lte-api.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "1.4.18";
|
2021-10-28 06:52:43 +00:00
|
|
|
src = fetchFromGitHub {
|
2021-12-06 16:07:01 +00:00
|
|
|
owner = "Salamek";
|
|
|
|
repo = "huawei-lte-api";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "1qaqxmh03j10wa9wqbwgc5r3ays8wfr7bldvsm45fycr3qfyn5fg";
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
2021-12-06 16:07:01 +00:00
|
|
|
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ python3.pkgs.dicttoxml ];
|
2021-10-28 06:52:43 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2021-04-12 18:23:04 +00: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-09-18 10:52:07 +00:00
|
|
|
# Pinned due to API changes in 0.1.0
|
2022-03-05 16:20:37 +00:00
|
|
|
(mkOverride "poolsense" "0.0.8" "sha256-17MHrYRmqkH+1QLtgq2d6zaRtqvb9ju9dvPt9gB2xCc=")
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
# Pinned due to API changes >0.3.5.3
|
|
|
|
(self: super: {
|
|
|
|
pyatag = super.pyatag.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "0.3.5.3";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "MatsNl";
|
|
|
|
repo = "pyatag";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "00ly4injmgrj34p0lyx7cz2crgnfcijmzc0540gf7hpwha0marf6";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
2022-01-19 23:45:15 +00:00
|
|
|
|
2021-12-19 01:06:50 +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-28 23:13:55 +00:00
|
|
|
# home-assistant-frontend does not exist in python3.pkgs
|
2020-04-24 23:36:52 +00:00
|
|
|
(self: super: {
|
2021-06-28 23:13:55 +00:00
|
|
|
home-assistant-frontend = self.callPackage ./frontend.nix { };
|
2020-04-24 23:36:52 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
mkOverride = attrName: version: hash:
|
2020-04-24 23:36:52 +00:00
|
|
|
self: super: {
|
2022-02-20 05:27:41 +00:00
|
|
|
${attrName} = super.${attrName}.overridePythonAttrs (oldAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit version;
|
|
|
|
src = oldAttrs.src.override {
|
2022-03-05 16:20:37 +00:00
|
|
|
inherit version hash;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
python = python3.override {
|
2020-04-24 23:36:52 +00:00
|
|
|
# Put packageOverrides at the start so they are applied after defaultOverrides
|
|
|
|
packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) ([ packageOverrides ] ++ defaultOverrides);
|
|
|
|
};
|
|
|
|
|
|
|
|
componentPackages = import ./component-packages.nix;
|
|
|
|
|
|
|
|
availableComponents = builtins.attrNames componentPackages.components;
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
inherit (componentPackages) supportedComponentsWithTests;
|
|
|
|
|
|
|
|
getPackages = component: componentPackages.components.${component};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
componentBuildInputs = lib.concatMap (component: getPackages component python.pkgs) extraComponents;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Ensure that we are using a consistent package set
|
2022-01-19 23:45:15 +00:00
|
|
|
extraBuildInputs = extraPackages python.pkgs;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
# Create info about included packages and components
|
|
|
|
extraComponentsFile = writeText "home-assistant-components" (lib.concatStringsSep "\n" extraComponents);
|
|
|
|
extraPackagesFile = writeText "home-assistant-packages" (lib.concatMapStringsSep "\n" (pkg: pkg.pname) extraBuildInputs);
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Don't forget to run parse-requirements.py after updating
|
2022-03-30 09:31:56 +00:00
|
|
|
hassVersion = "2022.3.8";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
in python.pkgs.buildPythonApplication rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "homeassistant";
|
|
|
|
version = assert (componentPackages.version == hassVersion); hassVersion;
|
2022-02-10 20:34:41 +00:00
|
|
|
format = "pyproject";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-11 12:50:04 +00:00
|
|
|
# check REQUIRED_PYTHON_VER in homeassistant/const.py
|
2022-02-10 20:34:41 +00:00
|
|
|
disabled = python.pythonOlder "3.9";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
# don't try and fail to strip 6600+ python files, it takes minutes!
|
|
|
|
dontStrip = true;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# PyPI tarball is missing tests/ directory
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "home-assistant";
|
2020-05-29 06:06:01 +00:00
|
|
|
repo = "core";
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = version;
|
2022-03-30 09:31:56 +00:00
|
|
|
hash = "sha256-FGsMFt/EEokaast81iiwKHqSsB1E4Si5ejTw+MV1MnQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
# leave this in, so users don't have to constantly update their downstream patch handling
|
2021-03-09 03:18:52 +00:00
|
|
|
patches = [
|
2021-12-19 01:06:50 +00:00
|
|
|
(substituteAll {
|
|
|
|
src = ./patches/ffmpeg-path.patch;
|
|
|
|
ffmpeg = "${lib.getBin ffmpeg}/bin/ffmpeg";
|
|
|
|
})
|
2021-03-09 03:18:52 +00:00
|
|
|
];
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2022-01-26 04:04:25 +00:00
|
|
|
postPatch = let
|
|
|
|
relaxedConstraints = [
|
|
|
|
"aiohttp"
|
|
|
|
"async_timeout"
|
|
|
|
"attrs"
|
|
|
|
"awesomeversion"
|
|
|
|
"bcrypt"
|
|
|
|
"cryptography"
|
|
|
|
"httpx"
|
|
|
|
"pip"
|
|
|
|
"PyJWT"
|
|
|
|
"requests"
|
|
|
|
"yarl"
|
|
|
|
];
|
|
|
|
in ''
|
|
|
|
sed -r -i \
|
|
|
|
${lib.concatStringsSep "\n" (map (package:
|
2022-02-10 20:34:41 +00:00
|
|
|
''-e 's@${package}[<>=]+.*@${package}@g' \''
|
2022-01-26 04:04:25 +00:00
|
|
|
) relaxedConstraints)}
|
2022-02-10 20:34:41 +00:00
|
|
|
setup.cfg
|
2020-10-11 12:50:04 +00:00
|
|
|
substituteInPlace tests/test_config.py --replace '"/usr"' '"/build/media"'
|
2020-09-25 04:45:31 +00:00
|
|
|
'';
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
propagatedBuildInputs = with python.pkgs; [
|
2021-06-28 23:13:55 +00:00
|
|
|
# Only packages required in setup.py
|
2021-02-05 17:12:51 +00:00
|
|
|
aiohttp
|
|
|
|
astral
|
|
|
|
async-timeout
|
2021-12-19 01:06:50 +00:00
|
|
|
atomicwrites
|
2021-02-05 17:12:51 +00:00
|
|
|
attrs
|
2021-02-13 14:23:35 +00:00
|
|
|
awesomeversion
|
2021-02-05 17:12:51 +00:00
|
|
|
bcrypt
|
|
|
|
certifi
|
|
|
|
ciso8601
|
|
|
|
cryptography
|
|
|
|
httpx
|
2021-12-30 13:39:12 +00:00
|
|
|
ifaddr
|
2021-02-05 17:12:51 +00:00
|
|
|
jinja2
|
|
|
|
pip
|
|
|
|
pyjwt
|
|
|
|
python-slugify
|
|
|
|
pytz
|
|
|
|
pyyaml
|
|
|
|
requests
|
2021-12-06 16:07:01 +00:00
|
|
|
ruamel-yaml
|
2021-02-05 17:12:51 +00:00
|
|
|
voluptuous
|
|
|
|
voluptuous-serialize
|
|
|
|
yarl
|
2021-06-28 23:13:55 +00:00
|
|
|
# Not in setup.py, but used in homeassistant/util/package.py
|
|
|
|
setuptools
|
2022-03-05 16:20:37 +00:00
|
|
|
# Not in setup.py, but uncounditionally imported via tests/conftest.py
|
|
|
|
paho-mqtt
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ componentBuildInputs ++ extraBuildInputs;
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
makeWrapperArgs = lib.optional skipPip "--add-flags --skip-pip";
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
# upstream only tests on Linux, so do we.
|
|
|
|
doCheck = stdenv.isLinux;
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
checkInputs = with python.pkgs; [
|
2021-05-20 23:08:51 +00:00
|
|
|
# test infrastructure (selectively from requirement_test.txt)
|
2021-12-06 16:07:01 +00:00
|
|
|
freezegun
|
2022-01-19 23:45:15 +00:00
|
|
|
jsonpickle
|
2021-02-05 17:12:51 +00:00
|
|
|
pytest-aiohttp
|
2021-12-06 16:07:01 +00:00
|
|
|
pytest-freezegun
|
2021-05-20 23:08:51 +00:00
|
|
|
pytest-mock
|
2021-03-09 03:18:52 +00:00
|
|
|
pytest-rerunfailures
|
2021-12-06 16:07:01 +00:00
|
|
|
pytest-socket
|
2021-02-05 17:12:51 +00:00
|
|
|
pytest-xdist
|
|
|
|
pytestCheckHook
|
|
|
|
requests-mock
|
2021-03-09 03:18:52 +00:00
|
|
|
respx
|
2022-01-19 23:45:15 +00:00
|
|
|
stdlib-list
|
|
|
|
tqdm
|
2022-02-10 20:34:41 +00:00
|
|
|
# required by tests/pylint
|
|
|
|
astroid
|
|
|
|
pylint
|
2021-05-20 23:08:51 +00:00
|
|
|
# required by tests/auth/mfa_modules
|
|
|
|
pyotp
|
2022-01-19 23:45:15 +00:00
|
|
|
] ++ lib.concatMap (component: getPackages component python.pkgs) [
|
|
|
|
# some components are needed even if tests in tests/components are disabled
|
2020-10-11 12:50:04 +00:00
|
|
|
"default_config"
|
2021-02-05 17:12:51 +00:00
|
|
|
"hue"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2020-10-11 12:50:04 +00:00
|
|
|
pytestFlagsArray = [
|
2021-05-20 23:08:51 +00:00
|
|
|
# parallelize test run
|
2021-09-18 10:52:07 +00:00
|
|
|
"--numprocesses $NIX_BUILD_CORES"
|
2021-05-20 23:08:51 +00:00
|
|
|
# assign tests grouped by file to workers
|
|
|
|
"--dist loadfile"
|
2021-03-09 03:18:52 +00:00
|
|
|
# retry racy tests that end in "RuntimeError: Event loop is closed"
|
|
|
|
"--reruns 3"
|
|
|
|
"--only-rerun RuntimeError"
|
2021-05-20 23:08:51 +00:00
|
|
|
# enable full variable printing on error
|
|
|
|
"--showlocals"
|
2021-08-08 23:34:03 +00:00
|
|
|
# helpers/test_system_info.py: AssertionError: assert 'Unknown' == 'Home Assistant Container'
|
|
|
|
"--deselect tests/helpers/test_system_info.py::test_container_installationtype"
|
2021-05-20 23:08:51 +00:00
|
|
|
# tests are located in tests/
|
|
|
|
"tests"
|
2022-01-19 23:45:15 +00:00
|
|
|
];
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2021-03-09 03:18:52 +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-11 12:50:04 +00:00
|
|
|
disabledTests = [
|
2021-02-13 14:23:35 +00:00
|
|
|
# AssertionError: assert 1 == 0
|
|
|
|
"test_merge"
|
2022-01-17 02:38:33 +00:00
|
|
|
# Tests are flaky
|
|
|
|
"test_config_platform_valid"
|
2020-10-11 12:50:04 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
preCheck = ''
|
2021-04-08 16:26:57 +00:00
|
|
|
export HOME="$TEMPDIR"
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
# the tests require the existance of a media dir
|
|
|
|
mkdir /build/media
|
2021-04-08 16:26:57 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
# put ping binary into PATH, e.g. for wake_on_lan tests
|
|
|
|
export PATH=${inetutils}/bin:$PATH
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
postInstall = ''
|
|
|
|
cp -v ${extraComponentsFile} $out/extra_components
|
|
|
|
cp -v ${extraPackagesFile} $out/extra_packages
|
|
|
|
'';
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
passthru = {
|
2022-01-19 23:45:15 +00:00
|
|
|
inherit
|
|
|
|
availableComponents
|
|
|
|
extraComponents
|
|
|
|
getPackages
|
|
|
|
python
|
|
|
|
supportedComponentsWithTests;
|
2020-06-15 15:56:04 +00:00
|
|
|
tests = {
|
2022-01-19 23:45:15 +00:00
|
|
|
nixos = nixosTests.home-assistant;
|
|
|
|
components = callPackage ./tests.nix { };
|
2020-06-15 15:56:04 +00:00
|
|
|
};
|
2020-05-15 21:57:56 +00:00
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://home-assistant.io/";
|
2020-10-16 20:44:37 +00:00
|
|
|
description = "Open source home automation that puts local control and privacy first";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
2021-04-08 16:26:57 +00:00
|
|
|
maintainers = teams.home-assistant.members;
|
2021-04-05 15:23:46 +00:00
|
|
|
platforms = platforms.linux;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|