nixpkgs/pkgs/servers/home-assistant/default.nix
2018-02-14 10:01:50 +01:00

92 lines
2.9 KiB
Nix

{ lib, fetchFromGitHub, python3
, extraComponents ? []
, extraPackages ? ps: []
, skipPip ? true }:
let
py = python3.override {
packageOverrides = self: super: {
yarl = super.yarl.overridePythonAttrs (oldAttrs: rec {
version = "1.1.0";
src = oldAttrs.src.override {
inherit version;
sha256 = "162630v7f98l27h11msk9416lqwm2mpgxh4s636594nlbfs9by3a";
};
});
aiohttp = super.aiohttp.overridePythonAttrs (oldAttrs: rec {
version = "2.3.10";
src = oldAttrs.src.override {
inherit version;
sha256 = "8adda6583ba438a4c70693374e10b60168663ffa6564c5c75d3c7a9055290964";
};
});
pytest = super.pytest.overridePythonAttrs (oldAttrs: rec {
version = "3.3.1";
src = oldAttrs.src.override {
inherit version;
sha256 = "14zbnbn53yvrpv79ch6n02myq9b4winjkaykzi356sfqb7f3d16g";
};
});
hass-frontend = super.callPackage ./frontend.nix { };
};
};
componentPackages = import ./component-packages.nix;
availableComponents = builtins.attrNames componentPackages.components;
getPackages = component: builtins.getAttr component componentPackages.components;
componentBuildInputs = map (component: getPackages component py.pkgs) extraComponents;
# Ensure that we are using a consistent package set
extraBuildInputs = extraPackages py.pkgs;
# Don't forget to run parse-requirements.py after updating
hassVersion = "0.63.2";
in with py.pkgs; buildPythonApplication rec {
pname = "homeassistant";
version = assert (componentPackages.version == hassVersion); hassVersion;
inherit availableComponents;
# PyPI tarball is missing tests/ directory
src = fetchFromGitHub {
owner = "home-assistant";
repo = "home-assistant";
rev = version;
sha256 = "057xp3l3amzxbzzdqmgbmd0qk6fz29lpdbw3zcbjigjxbdi14h2l";
};
propagatedBuildInputs = [
# From setup.py
requests pyyaml pytz pip jinja2 voluptuous typing aiohttp yarl async-timeout chardet astral certifi attrs
# From http, frontend and recorder components
sqlalchemy aiohttp-cors hass-frontend user-agents
] ++ componentBuildInputs ++ extraBuildInputs;
checkInputs = [
pytest requests-mock pydispatcher pytest-aiohttp
];
checkPhase = ''
# The components' dependencies are not included, so they cannot be tested
py.test --ignore tests/components
# Some basic components should be tested however
py.test \
tests/components/{group,http} \
tests/components/test_{api,configurator,demo,discovery,frontend,init,introduction,logger,script,shell_command,system_log,websocket_api}.py
'';
makeWrapperArgs = lib.optional skipPip "--add-flags --skip-pip";
meta = with lib; {
homepage = https://home-assistant.io/;
description = "Open-source home automation platform running on Python 3";
license = licenses.asl20;
maintainers = with maintainers; [ f-breidenstein dotlambda ];
};
}