Merge pull request #34188 from dotlambda/home-assistant

home-assistant: init at 0.62.1

Changed files
+273 -3
lib
nixos
pkgs
development
python-modules
aiohttp
astral
pytest-aiohttp
servers
home-assistant
top-level
+1
lib/maintainers.nix
···
fadenb = "Tristan Helmich <tristan.helmich+nixos@gmail.com>";
falsifian = "James Cook <james.cook@utoronto.ca>";
fare = "Francois-Rene Rideau <fahree@gmail.com>";
+
f-breidenstein = "Felix Breidenstein <mail@felixbreidenstein.de>";
fgaz = "Francesco Gazzetta <francygazz@gmail.com>";
FireyFly = "Jonas Höglund <nix@firefly.nu>";
flokli = "Florian Klink <flokli@flokli.de>";
+2
nixos/modules/misc/ids.nix
···
kodi = 283;
restya-board = 284;
mighttpd2 = 285;
+
hass = 286;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
···
kodi = 283;
restya-board = 284;
mighttpd2 = 285;
+
hass = 286;
# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal
+1
nixos/modules/module-list.nix
···
./services/misc/gogs.nix
./services/misc/gollum.nix
./services/misc/gpsd.nix
+
./services/misc/home-assistant.nix
./services/misc/ihaskell.nix
./services/misc/irkerd.nix
./services/misc/jackett.nix
+90
nixos/modules/services/misc/home-assistant.nix
···
+
{ config, lib, pkgs, ... }:
+
+
with lib;
+
+
let
+
cfg = config.services.home-assistant;
+
+
configFile = pkgs.writeText "configuration.yaml" (builtins.toJSON cfg.config);
+
in {
+
meta.maintainers = with maintainers; [ dotlambda ];
+
+
options.services.home-assistant = {
+
enable = mkEnableOption "Home Assistant";
+
+
configDir = mkOption {
+
default = "/var/lib/hass";
+
type = types.path;
+
description = "The config directory, where your <filename>configuration.yaml</filename> is located.";
+
};
+
+
config = mkOption {
+
default = null;
+
type = with types; nullOr attrs;
+
example = literalExample ''
+
{
+
homeassistant = {
+
name = "Home";
+
time_zone = "UTC";
+
};
+
frontend = { };
+
http = { };
+
}
+
'';
+
description = ''
+
Your <filename>configuration.yaml</filename> as a Nix attribute set.
+
Beware that setting this option will delete your previous <filename>configuration.yaml</filename>.
+
'';
+
};
+
+
package = mkOption {
+
default = pkgs.home-assistant;
+
defaultText = "pkgs.home-assistant";
+
type = types.package;
+
example = literalExample ''
+
pkgs.home-assistant.override {
+
extraPackages = ps: with ps; [ colorlog ];
+
}
+
'';
+
description = ''
+
Home Assistant package to use.
+
Most Home Assistant components require additional dependencies,
+
which are best specified by overriding <literal>pkgs.home-assistant</literal>.
+
You can find the dependencies by searching for failed imports in your log or by looking at this list:
+
<link xlink:href="https://github.com/home-assistant/home-assistant/blob/master/requirements_all.txt"/>
+
'';
+
};
+
};
+
+
config = mkIf cfg.enable {
+
systemd.services.home-assistant = {
+
description = "Home Assistant";
+
wantedBy = [ "multi-user.target" ];
+
after = [ "network.target" ];
+
preStart = lib.optionalString (cfg.config != null) ''
+
rm -f ${cfg.configDir}/configuration.yaml
+
ln -s ${configFile} ${cfg.configDir}/configuration.yaml
+
'';
+
serviceConfig = {
+
ExecStart = ''
+
${cfg.package}/bin/hass --config "${cfg.configDir}"
+
'';
+
User = "hass";
+
Group = "hass";
+
Restart = "on-failure";
+
ProtectSystem = "strict";
+
ReadWritePaths = "${cfg.configDir}";
+
PrivateTmp = true;
+
};
+
};
+
+
users.extraUsers.hass = {
+
home = cfg.configDir;
+
createHome = true;
+
group = "hass";
+
uid = config.ids.uids.hass;
+
};
+
+
users.extraGroups.hass.gid = config.ids.gids.hass;
+
};
+
}
+1
nixos/release.nix
···
tests.graphite = callTest tests/graphite.nix {};
tests.hardened = callTest tests/hardened.nix { };
tests.hibernate = callTest tests/hibernate.nix {};
+
tests.home-assistant = callTest tests/home-assistant.nix { };
tests.hound = callTest tests/hound.nix {};
tests.i3wm = callTest tests/i3wm.nix {};
tests.initrd-network-ssh = callTest tests/initrd-network-ssh {};
+41
nixos/tests/home-assistant.nix
···
+
import ./make-test.nix ({ pkgs, ... }:
+
+
let
+
configDir = "/var/lib/foobar";
+
+
in {
+
name = "home-assistant";
+
+
nodes = {
+
hass =
+
{ config, pkgs, ... }:
+
{
+
services.home-assistant = {
+
inherit configDir;
+
enable = true;
+
config = {
+
homeassistant = {
+
name = "Home";
+
time_zone = "UTC";
+
};
+
frontend = { };
+
http = { };
+
};
+
};
+
};
+
};
+
+
testScript = ''
+
startAll;
+
$hass->waitForUnit("home-assistant.service");
+
+
# Since config is specified using a Nix attribute set,
+
# configuration.yaml is a link to the Nix store
+
$hass->succeed("test -L ${configDir}/configuration.yaml");
+
+
# Check that Home Assistant's web interface and API can be reached
+
$hass->waitForOpenPort(8123);
+
$hass->succeed("curl --fail http://localhost:8123/states");
+
$hass->succeed("curl --fail http://localhost:8123/api/ | grep 'API running'");
+
'';
+
})
+1 -1
pkgs/development/python-modules/aiohttp/cors.nix
···
buildPythonPackage rec {
pname = "aiohttp-cors";
version = "0.6.0";
-
name = "${pname}-${version}";
+
src = fetchPypi {
inherit pname version;
sha256 = "1r0mb4dw0dc1lpi54dk5vxqs06nyhvagp76lyrvk7rd94z5mjkd4";
+1 -2
pkgs/development/python-modules/aiohttp/default.nix
···
buildPythonPackage rec {
pname = "aiohttp";
version = "2.3.9";
-
name = "${pname}-${version}";
src = fetchPypi {
inherit pname version;
···
license = with lib.licenses; [ asl20 ];
homepage = https://github.com/KeepSafe/aiohttp/;
};
-
}
+
}
+26
pkgs/development/python-modules/astral/default.nix
···
+
{ stdenv, buildPythonPackage, fetchPypi, pytz, pytest }:
+
+
buildPythonPackage rec {
+
pname = "astral";
+
version = "1.4";
+
+
src = fetchPypi {
+
inherit pname version;
+
extension = "zip";
+
sha256 = "1zm1ypc6w279gh7lbgsfbzfxk2x4gihlq3rfh59hj70hmhjwiwp7";
+
};
+
+
propagatedBuildInputs = [ pytz ];
+
+
checkInputs = [ pytest ];
+
checkPhase = ''
+
py.test -k "not test_GoogleLocator"
+
'';
+
+
meta = with stdenv.lib; {
+
description = "Calculations for the position of the sun and the moon";
+
homepage = https://github.com/sffjunkie/astral/;
+
license = licenses.asl20;
+
maintainers = with maintainers; [ flokli ];
+
};
+
}
+20
pkgs/development/python-modules/pytest-aiohttp/default.nix
···
+
{ stdenv, buildPythonPackage, fetchPypi, pytest, aiohttp }:
+
+
buildPythonPackage rec {
+
pname = "pytest-aiohttp";
+
version = "0.3.0";
+
+
src = fetchPypi {
+
inherit pname version;
+
sha256 = "0kx4mbs9bflycd8x9af0idcjhdgnzri3nw1qb0vpfyb3751qaaf9";
+
};
+
+
propagatedBuildInputs = [ pytest aiohttp ];
+
+
meta = with stdenv.lib; {
+
homepage = https://github.com/aio-libs/pytest-aiohttp/;
+
description = "Pytest plugin for aiohttp support";
+
license = licenses.asl20;
+
maintainers = with maintainers; [ dotlambda ];
+
};
+
}
+72
pkgs/servers/home-assistant/default.nix
···
+
{ stdenv, fetchFromGitHub, python3
+
, extraPackages ? ps: []
+
, skipPip ? true }:
+
+
let
+
+
py = python3.override {
+
packageOverrides = self: super: {
+
yarl = super.yarl.overridePythonAttrs (oldAttrs: rec {
+
version = "0.18.0";
+
src = oldAttrs.src.override {
+
inherit version;
+
sha256 = "11j8symkxh0ngvpddqpj85qmk6p70p20jca3alxc181gk3vx785s";
+
};
+
});
+
aiohttp = super.aiohttp.overridePythonAttrs (oldAttrs: rec {
+
version = "2.3.7";
+
src = oldAttrs.src.override {
+
inherit version;
+
sha256 = "0fzfpx5ny7559xrxaawnylq20dvrkjiag0ypcd13frwwivrlsagy";
+
};
+
});
+
hass-frontend = super.callPackage ./frontend.nix { };
+
};
+
};
+
+
# Ensure that we are using a consistent package set
+
extraBuildInputs = extraPackages py.pkgs;
+
+
in with py.pkgs; buildPythonApplication rec {
+
pname = "homeassistant";
+
version = "0.62.1";
+
+
diabled = !isPy3k;
+
+
# PyPI tarball is missing tests/ directory
+
src = fetchFromGitHub {
+
owner = "home-assistant";
+
repo = "home-assistant";
+
rev = version;
+
sha256 = "0151prwk2ci6bih0mdmc3r328nrvazn9jwk0w26wmd4cpvnb5h26";
+
};
+
+
propagatedBuildInputs = [
+
# From setup.py
+
requests pyyaml pytz pip jinja2 voluptuous typing aiohttp yarl async-timeout chardet astral certifi
+
# From the components that are part of the default configuration.yaml
+
sqlalchemy aiohttp-cors hass-frontend user-agents distro mutagen xmltodict netdisco
+
] ++ 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 = [] ++ stdenv.lib.optional skipPip [ "--add-flags --skip-pip" ];
+
+
meta = with stdenv.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 ];
+
};
+
}
+11
pkgs/servers/home-assistant/frontend.nix
···
+
{ stdenv, fetchPypi, buildPythonPackage }:
+
+
buildPythonPackage rec {
+
pname = "home-assistant-frontend";
+
version = "20180130.0";
+
+
src = fetchPypi {
+
inherit pname version;
+
sha256 = "0b9klisl7hh30rml8qlrp9gpz33z9b825pd1vxbck48k0s98z1zi";
+
};
+
}
+2
pkgs/top-level/all-packages.nix
···
hiawatha = callPackage ../servers/http/hiawatha {};
+
home-assistant = callPackage ../servers/home-assistant { };
+
ircdHybrid = callPackage ../servers/irc/ircd-hybrid { };
jboss = callPackage ../servers/http/jboss { };
+4
pkgs/top-level/python-packages.nix
···
asn1crypto = callPackage ../development/python-modules/asn1crypto { };
+
astral = callPackage ../development/python-modules/astral { };
+
astropy = callPackage ../development/python-modules/astropy { };
augeas = callPackage ../development/python-modules/augeas {
···
pytest-httpbin = callPackage ../development/python-modules/pytest-httpbin { };
pytest-asyncio = callPackage ../development/python-modules/pytest-asyncio { };
+
+
pytest-aiohttp = callPackage ../development/python-modules/pytest-aiohttp { };
pytestcache = buildPythonPackage rec {
name = "pytest-cache-1.0";