Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
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>";
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/misc/ids.nix
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
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!

Expand Down Expand Up @@ -572,6 +573,7 @@
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
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@
./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
Expand Down
90 changes: 90 additions & 0 deletions nixos/modules/services/misc/home-assistant.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{ 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 change: 1 addition & 0 deletions nixos/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ in rec {
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 {};
Expand Down
41 changes: 41 additions & 0 deletions nixos/tests/home-assistant.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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'");
'';
})
2 changes: 1 addition & 1 deletion pkgs/development/python-modules/aiohttp/cors.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
buildPythonPackage rec {
pname = "aiohttp-cors";
version = "0.6.0";
name = "${pname}-${version}";

src = fetchPypi {
inherit pname version;
sha256 = "1r0mb4dw0dc1lpi54dk5vxqs06nyhvagp76lyrvk7rd94z5mjkd4";
Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/python-modules/aiohttp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
buildPythonPackage rec {
pname = "aiohttp";
version = "2.3.9";
name = "${pname}-${version}";

src = fetchPypi {
inherit pname version;
Expand All @@ -33,4 +32,4 @@ buildPythonPackage rec {
license = with lib.licenses; [ asl20 ];
homepage = https://github.com/KeepSafe/aiohttp/;
};
}
}
26 changes: 26 additions & 0 deletions pkgs/development/python-modules/astral/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ 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 changes: 20 additions & 0 deletions pkgs/development/python-modules/pytest-aiohttp/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ 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 changes: 72 additions & 0 deletions pkgs/servers/home-assistant/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{ 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I'll remove it with the next update.


# 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 changes: 11 additions & 0 deletions pkgs/servers/home-assistant/frontend.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ stdenv, fetchPypi, buildPythonPackage }:

buildPythonPackage rec {
pname = "home-assistant-frontend";
version = "20180130.0";

src = fetchPypi {
inherit pname version;
sha256 = "0b9klisl7hh30rml8qlrp9gpz33z9b825pd1vxbck48k0s98z1zi";
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11974,6 +11974,8 @@ with pkgs;

hiawatha = callPackage ../servers/http/hiawatha {};

home-assistant = callPackage ../servers/home-assistant { };

ircdHybrid = callPackage ../servers/irc/ircd-hybrid { };

jboss = callPackage ../servers/http/jboss { };
Expand Down
4 changes: 4 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ in {

asn1crypto = callPackage ../development/python-modules/asn1crypto { };

astral = callPackage ../development/python-modules/astral { };

astropy = callPackage ../development/python-modules/astropy { };

augeas = callPackage ../development/python-modules/augeas {
Expand Down Expand Up @@ -3215,6 +3217,8 @@ in {

pytest-asyncio = callPackage ../development/python-modules/pytest-asyncio { };

pytest-aiohttp = callPackage ../development/python-modules/pytest-aiohttp { };

pytestcache = buildPythonPackage rec {
name = "pytest-cache-1.0";
src = pkgs.fetchurl {
Expand Down