2019-10-22 21:36:09 +02:00
|
|
|
{ lib, fetchurl, fetchFromGitHub, fetchpatch, python3, protobuf3_6
|
2018-07-29 21:49:46 +02:00
|
|
|
|
|
|
|
# Look up dependencies of specified components in component-packages.nix
|
2018-02-01 13:42:07 +01:00
|
|
|
, extraComponents ? []
|
2018-07-29 21:49:46 +02:00
|
|
|
|
|
|
|
# Additional packages to add to propagatedBuildInputs
|
2018-01-14 22:26:52 +01:00
|
|
|
, extraPackages ? ps: []
|
2018-07-29 21:49:46 +02:00
|
|
|
|
2018-08-21 02:27:55 +02:00
|
|
|
# Override Python packages using
|
|
|
|
# self: super: { pkg = super.pkg.overridePythonAttrs (oldAttrs: { ... }); }
|
|
|
|
# Applied after defaultOverrides
|
2019-10-22 21:36:09 +02:00
|
|
|
, packageOverrides ? self: super: {
|
|
|
|
# TODO: Remove this override after updating to cryptography 2.8:
|
2019-10-29 14:44:21 +01:00
|
|
|
|
2019-10-22 21:36:09 +02:00
|
|
|
}
|
2018-08-21 02:27:55 +02:00
|
|
|
|
2018-07-29 21:49:46 +02:00
|
|
|
# Skip pip install of required packages on startup
|
2018-01-14 22:26:52 +01:00
|
|
|
, skipPip ? true }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2018-08-21 02:27:55 +02:00
|
|
|
defaultOverrides = [
|
2018-06-26 22:36:14 +02:00
|
|
|
# Override the version of some packages pinned in Home Assistant's setup.py
|
2019-10-29 15:06:01 +01:00
|
|
|
# (mkOverride "aiohttp" "3.5.4"
|
|
|
|
# "9c4c83f4fa1938377da32bc2d59379025ceeee8e24b89f72fcbccd8ca22dc9bf")
|
|
|
|
# (mkOverride "astral" "1.10.1"
|
|
|
|
# "d2a67243c4503131c856cafb1b1276de52a86e5b8a1d507b7e08bee51cb67bf1")
|
|
|
|
# (mkOverride "async-timeout" "3.0.1"
|
|
|
|
# "0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f")
|
|
|
|
# (mkOverride "bcrypt" "3.1.7"
|
|
|
|
# "0b0069c752ec14172c5f78208f1863d7ad6755a6fae6fe76ec2c80d13be41e42")
|
|
|
|
# (mkOverride "pyjwt" "1.7.1"
|
|
|
|
# "8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96")
|
2019-10-29 14:44:21 +01:00
|
|
|
(mkOverride "cryptography" "2.7" # TODO for 2.8: Remove the override below
|
2019-07-20 04:29:51 +02:00
|
|
|
"e6347742ac8f35ded4a46ff835c60e68c22a536a8ae5c4422966d06946b6d4c6")
|
|
|
|
(mkOverride "cryptography_vectors" "2.7" # required by cryptography==2.7
|
|
|
|
"f12dfb9bd669a68004074cb5b26df6e93ed1a95ebd1a999dff0a840212ff68bc")
|
2019-10-29 15:06:01 +01:00
|
|
|
# (mkOverride "importlib-metadata" "0.18"
|
|
|
|
# "cb6ee23b46173539939964df59d3d72c3e0c1b5d54b84f1d8a7e912fe43612db")
|
|
|
|
(mkOverride "python-slugify" "3.0.4"
|
|
|
|
"0dv97yi5fq074q5qyqbin09pmi8ixg36caf5nkpw2bqkd8jh6pap")
|
|
|
|
# (mkOverride "pyyaml" "5.1.1"
|
|
|
|
# "b4bb4d3f5e232425e25dda21c070ce05168a786ac9eda43768ab7f3ac2770955")
|
|
|
|
# (mkOverride "requests" "2.22.0"
|
|
|
|
# "11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4")
|
|
|
|
# (mkOverride "ruamel_yaml" "0.15.97"
|
|
|
|
# "17dbf6b7362e7aee8494f7a0f5cffd44902a6331fe89ef0853b855a7930ab845")
|
|
|
|
# (mkOverride "voluptuous" "0.11.5"
|
|
|
|
# "567a56286ef82a9d7ae0628c5842f65f516abcb496e74f3f59f1d7b28df314ef")
|
|
|
|
# (mkOverride "voluptuous-serialize" "2.1.0"
|
|
|
|
# "d30fef4f1aba251414ec0b315df81a06da7bf35201dcfb1f6db5253d738a154f")
|
2018-08-21 02:27:55 +02:00
|
|
|
|
2018-11-10 13:42:15 +01:00
|
|
|
# used by auth.mfa_modules.totp
|
2019-05-20 15:40:43 +02:00
|
|
|
(mkOverride "pyotp" "2.2.7"
|
|
|
|
"be0ffeabddaa5ee53e7204e7740da842d070cf69168247a3d0c08541b84de602")
|
2018-11-10 13:42:15 +01:00
|
|
|
|
2018-08-21 02:27:55 +02:00
|
|
|
# used by check_config script
|
|
|
|
# can be unpinned once https://github.com/home-assistant/home-assistant/issues/11917 is resolved
|
2019-01-11 23:40:58 +01:00
|
|
|
(mkOverride "colorlog" "4.0.2"
|
|
|
|
"3cf31b25cbc8f86ec01fef582ef3b840950dea414084ed19ab922c8b493f9b42")
|
2018-08-21 02:27:55 +02:00
|
|
|
|
2019-04-22 23:35:37 +02:00
|
|
|
# required by aioesphomeapi
|
|
|
|
(self: super: {
|
|
|
|
protobuf = super.protobuf.override {
|
|
|
|
protobuf = protobuf3_6;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
2019-10-29 14:44:21 +01:00
|
|
|
(self: super: {
|
|
|
|
# TODO: Remove this override after updating to cryptography 2.8
|
|
|
|
cryptography = super.cryptography.overridePythonAttrs (oldAttrs: {
|
|
|
|
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ super.asn1crypto ];
|
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/pyca/cryptography/commit/e575e3d482f976c4a1f3203d63ea0f5007a49a2a.patch";
|
|
|
|
sha256 = "0vg9prqsizd6gzh5j7lscsfxzxlhz7pacvzhgqmj1vhdhjwbblcp";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2018-12-12 14:01:39 +01:00
|
|
|
# hass-frontend does not exist in python3.pkgs
|
2018-08-21 02:27:55 +02:00
|
|
|
(self: super: {
|
|
|
|
hass-frontend = self.callPackage ./frontend.nix { };
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
mkOverride = attrname: version: sha256:
|
|
|
|
self: super: {
|
|
|
|
${attrname} = super.${attrname}.overridePythonAttrs (oldAttrs: {
|
|
|
|
inherit version;
|
2018-05-11 19:39:37 +02:00
|
|
|
src = oldAttrs.src.override {
|
2018-08-21 02:27:55 +02:00
|
|
|
inherit version sha256;
|
2018-05-11 19:39:37 +02:00
|
|
|
};
|
|
|
|
});
|
2018-01-14 22:26:52 +01:00
|
|
|
};
|
2019-07-25 11:51:55 +02:00
|
|
|
|
2018-12-12 14:01:39 +01:00
|
|
|
py = python3.override {
|
2018-08-21 02:27:55 +02:00
|
|
|
# Put packageOverrides at the start so they are applied after defaultOverrides
|
|
|
|
packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) ([ packageOverrides ] ++ defaultOverrides);
|
2018-01-14 22:26:52 +01:00
|
|
|
};
|
|
|
|
|
2018-02-01 13:42:07 +01:00
|
|
|
componentPackages = import ./component-packages.nix;
|
|
|
|
|
|
|
|
availableComponents = builtins.attrNames componentPackages.components;
|
|
|
|
|
|
|
|
getPackages = component: builtins.getAttr component componentPackages.components;
|
|
|
|
|
2018-04-08 13:21:52 +02:00
|
|
|
componentBuildInputs = lib.concatMap (component: getPackages component py.pkgs) extraComponents;
|
2018-02-01 13:42:07 +01:00
|
|
|
|
2018-01-14 22:26:52 +01:00
|
|
|
# Ensure that we are using a consistent package set
|
|
|
|
extraBuildInputs = extraPackages py.pkgs;
|
|
|
|
|
2018-02-01 13:42:07 +01:00
|
|
|
# Don't forget to run parse-requirements.py after updating
|
2019-10-29 15:06:01 +01:00
|
|
|
hassVersion = "0.100.3";
|
2018-02-01 13:42:07 +01:00
|
|
|
|
2018-01-14 22:26:52 +01:00
|
|
|
in with py.pkgs; buildPythonApplication rec {
|
|
|
|
pname = "homeassistant";
|
2018-02-01 13:42:07 +01:00
|
|
|
version = assert (componentPackages.version == hassVersion); hassVersion;
|
2018-01-14 22:26:52 +01:00
|
|
|
|
2018-03-14 18:48:50 +01:00
|
|
|
disabled = pythonOlder "3.5";
|
|
|
|
|
2018-02-01 13:42:07 +01:00
|
|
|
inherit availableComponents;
|
2018-01-14 22:26:52 +01:00
|
|
|
|
|
|
|
# PyPI tarball is missing tests/ directory
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "home-assistant";
|
|
|
|
repo = "home-assistant";
|
|
|
|
rev = version;
|
2019-10-29 15:06:01 +01:00
|
|
|
sha256 = "1rrv71h91qjq5sii4wfcdjvrcpid2aci1dwadrcd35363ff0w200";
|
2018-01-14 22:26:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
# From setup.py
|
2019-07-20 04:29:51 +02:00
|
|
|
aiohttp astral async-timeout attrs bcrypt certifi importlib-metadata jinja2
|
|
|
|
pyjwt cryptography pip python-slugify pytz pyyaml requests ruamel_yaml
|
2019-09-14 15:23:26 +02:00
|
|
|
setuptools voluptuous voluptuous-serialize
|
2018-10-17 14:56:55 +02:00
|
|
|
# From http, frontend and recorder components and auth.mfa_modules.totp
|
|
|
|
sqlalchemy aiohttp-cors hass-frontend pyotp pyqrcode
|
2018-02-01 13:42:07 +01:00
|
|
|
] ++ componentBuildInputs ++ extraBuildInputs;
|
2018-01-14 22:26:52 +01:00
|
|
|
|
|
|
|
checkInputs = [
|
2019-04-25 12:52:07 +02:00
|
|
|
asynctest pytest pytest-aiohttp requests-mock pydispatcher aiohue
|
2018-01-14 22:26:52 +01:00
|
|
|
];
|
|
|
|
|
2019-10-29 15:06:01 +01:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace "aiohttp==3.6.1" "aiohttp" \
|
|
|
|
--replace "attrs==19.2.0" "attrs" \
|
|
|
|
--replace "ruamel.yaml==0.15.100" "ruamel.yaml"
|
|
|
|
'';
|
|
|
|
|
2018-01-14 22:26:52 +01:00
|
|
|
checkPhase = ''
|
|
|
|
# The components' dependencies are not included, so they cannot be tested
|
2019-04-25 12:52:07 +02:00
|
|
|
# test_webhook_create_cloudhook imports hass_nabucasa and is thus excluded
|
2019-10-29 15:06:01 +01:00
|
|
|
py.test --ignore tests/components -k "not test_webhook_create_cloudhook and not test_webhook_config_flow_registers_webhook"
|
2018-01-14 22:26:52 +01:00
|
|
|
# Some basic components should be tested however
|
2018-05-11 19:39:37 +02:00
|
|
|
py.test \
|
2019-03-04 17:23:55 +01:00
|
|
|
tests/components/{api,config,configurator,demo,discovery,frontend,group,history,history_graph} \
|
2019-04-25 12:52:07 +02:00
|
|
|
tests/components/{homeassistant,http,logger,script,shell_command,system_log,websocket_api}
|
2018-01-14 22:26:52 +01:00
|
|
|
'';
|
|
|
|
|
2018-02-10 23:19:19 +01:00
|
|
|
makeWrapperArgs = lib.optional skipPip "--add-flags --skip-pip";
|
2018-01-14 22:26:52 +01:00
|
|
|
|
2018-02-10 23:19:19 +01:00
|
|
|
meta = with lib; {
|
2018-01-14 22:26:52 +01:00
|
|
|
homepage = https://home-assistant.io/;
|
|
|
|
description = "Open-source home automation platform running on Python 3";
|
|
|
|
license = licenses.asl20;
|
2019-10-21 11:16:16 +02:00
|
|
|
maintainers = with maintainers; [ dotlambda globin ];
|
2018-01-14 22:26:52 +01:00
|
|
|
};
|
|
|
|
}
|