all repos — nixfiles @ 3ab45a6b7b20b7da2239ba1c3a25e5ff4b7774c1

System and user configuration, managed by nix and home-manager

home-automation: init module

Alin
commit

3ab45a6b7b20b7da2239ba1c3a25e5ff4b7774c1

parent

256bd605be5d23aae11c93cc97ba533e7b67c69e

3 files changed, 76 insertions(+), 0 deletions(-)

changed files
M system/hosts/r5.nix → system/hosts/r5.nix
@@ -18,6 +18,7 @@ ../roles/local-ca.nix
../roles/dynamic-dns.nix ../roles/exit-node.nix ../roles/syncthing.nix + ../roles/home-automation.nix ../roles/tailscale-subnet-router.nix ../settings/hardware/usb-serial-tty.nix ];
A system/roles/home-automation.nix
@@ -0,0 +1,68 @@
+{ + config, + ... +}: +let + inherit (config.networking) hostName domain; +in +{ + imports = [ + ./postgresql.nix + ]; + + services.home-assistant = { + enable = true; + extraPackages = ps: with ps; [ psycopg2 ]; + extraComponents = [ + # Components required to complete the onboarding + "analytics" + "google_translate" + "met" + "radio_browser" + "shopping_list" + # Recommended for fast zlib compression + # https://www.home-assistant.io/integrations/isal + "isal" + ]; + config = { + default_config = { }; + recorder.db_url = "postgresql://@/hass"; + http = { + server_host = "::1"; + use_x_forwarded_for = true; + trusted_proxies = "::1"; + }; + }; + }; + + services.matter-server = { + enable = true; + }; + + services.postgresql = { + ensureDatabases = [ "hass" ]; + ensureUsers = [ + { + name = "hass"; + ensureDBOwnership = true; + } + ]; + }; + + services.caddy.virtualHosts = { + "ha.${domain}" = { + extraConfig = '' + tls { + issuer internal { + ca home + } + } + reverse_proxy http://[::1]:8123 + ''; + }; + }; + + services.dnsmasq.settings.cname = [ + "ha.${domain},${hostName}.${domain}" + ]; +}
A system/roles/postgresql.nix
@@ -0,0 +1,7 @@
+{ + services.postgresql = { + enable = true; + dataDir = "/srv/postgresql"; + }; + users.users.postgres.createHome = true; +}