1
0
Fork 0
selfhostblocks/test/services/home-assistant.nix

139 lines
2.5 KiB
Nix
Raw Normal View History

2024-05-25 02:56:36 +02:00
{ pkgs, lib, ... }:
let
pkgs' = pkgs;
2024-07-12 13:01:26 +02:00
testLib = pkgs.callPackage ../common.nix {};
2024-05-25 02:56:36 +02:00
subdomain = "ha";
domain = "example.com";
2024-07-16 10:38:26 +02:00
commonTestScript = lib.makeOverridable testLib.accessScript {
inherit subdomain domain;
2024-07-12 13:01:26 +02:00
hasSSL = { node, ... }: !(isNull node.config.shb.home-assistant.ssl);
waitForServices = { ... }: [
"home-assistant.service"
"nginx.service"
];
waitForPorts = { node, ... }: [
8123
];
};
2024-05-25 02:56:36 +02:00
2024-07-16 10:38:26 +02:00
base = testLib.base pkgs' [
../../modules/services/home-assistant.nix
];
2024-05-25 02:56:36 +02:00
basic = { config, ... }: {
shb.home-assistant = {
enable = true;
inherit subdomain domain;
config = {
name = "Tiserbox";
country = "My Country";
latitude = "01.0000000000";
longitude.source = pkgs.writeText "longitude" "01.0000000000";
time_zone = "America/Los_Angeles";
unit_system = "metric";
};
};
};
2024-07-16 10:38:26 +02:00
https = { config, ...}: {
shb.home-assistant = {
ssl = config.shb.certs.certs.selfsigned.n;
2024-05-25 02:56:36 +02:00
};
2024-07-16 10:38:26 +02:00
};
2024-05-25 02:56:36 +02:00
2024-07-16 10:38:26 +02:00
ldap = { config, ... }: {
2024-05-25 02:56:36 +02:00
shb.home-assistant = {
ldap = {
enable = true;
host = "127.0.0.1";
port = config.shb.ldap.webUIListenPort;
userGroup = "homeassistant_user";
};
};
};
# Not yet supported
#
# sso = { config, ... }: {
2024-07-16 10:38:26 +02:00
# shb.home-assistant = {
# sso = {
2024-05-25 02:56:36 +02:00
# };
# };
# };
in
{
basic = pkgs.testers.runNixOSTest {
2024-07-16 10:38:26 +02:00
name = "homeassistant_basic";
nodes.server = {
imports = [
base
basic
];
};
nodes.client = {};
testScript = commonTestScript;
};
https = pkgs.testers.runNixOSTest {
name = "homeassistant_https";
nodes.server = {
imports = [
base
(testLib.certs domain)
basic
https
];
};
2024-05-25 02:56:36 +02:00
nodes.client = {};
testScript = commonTestScript;
};
ldap = pkgs.testers.runNixOSTest {
2024-07-16 10:38:26 +02:00
name = "homeassistant_ldap";
2024-05-25 02:56:36 +02:00
2024-07-16 10:38:26 +02:00
nodes.server = {
imports = [
base
basic
(testLib.ldap domain pkgs')
ldap
];
};
2024-05-25 02:56:36 +02:00
nodes.client = {};
testScript = commonTestScript;
};
# Not yet supported
#
# sso = pkgs.testers.runNixOSTest {
# name = "vaultwarden_sso";
#
# nodes.server = lib.mkMerge [
# base
2024-07-16 10:38:26 +02:00
# (testLib.certs domain)
2024-05-25 02:56:36 +02:00
# basic
2024-07-16 10:38:26 +02:00
# https
2024-05-25 02:56:36 +02:00
# ldap
2024-07-16 10:38:26 +02:00
# (testLib.ldap domain pkgs')
# (testLib.sso domain pkgs' config.shb.certs.certs.selfsigned.n)
2024-05-25 02:56:36 +02:00
# sso
# ];
#
# nodes.client = {};
#
# testScript = commonTestScript;
# };
}