summary refs log tree commit diff
path: root/nixos/tests/home-assistant.nix
diff options
context:
space:
mode:
authorRobert Schütz <robert.schuetz@stud.uni-heidelberg.de>2018-01-26 01:41:36 +0100
committerRobert Schütz <robert.schuetz@stud.uni-heidelberg.de>2018-01-31 12:34:58 +0100
commit0604c078a8a61faaf179908551dc6ffe82f75b8b (patch)
treea2eed1d1b8a656cf8972f3c00310073348d250b1 /nixos/tests/home-assistant.nix
parentbacbc48cfe7d615a43c4c9df78d4c07982200cdd (diff)
downloadnixlib-0604c078a8a61faaf179908551dc6ffe82f75b8b.tar
nixlib-0604c078a8a61faaf179908551dc6ffe82f75b8b.tar.gz
nixlib-0604c078a8a61faaf179908551dc6ffe82f75b8b.tar.bz2
nixlib-0604c078a8a61faaf179908551dc6ffe82f75b8b.tar.lz
nixlib-0604c078a8a61faaf179908551dc6ffe82f75b8b.tar.xz
nixlib-0604c078a8a61faaf179908551dc6ffe82f75b8b.tar.zst
nixlib-0604c078a8a61faaf179908551dc6ffe82f75b8b.zip
home-assistant: add NixOS test
Diffstat (limited to 'nixos/tests/home-assistant.nix')
-rw-r--r--nixos/tests/home-assistant.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/nixos/tests/home-assistant.nix b/nixos/tests/home-assistant.nix
new file mode 100644
index 000000000000..0e2fee8e808d
--- /dev/null
+++ b/nixos/tests/home-assistant.nix
@@ -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'");
+  '';
+})