summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-09-13 12:12:36 +0530
committersinanmohd <sinan@sinanmohd.com>2024-09-13 12:19:13 +0530
commit8b148d39345ec9d06298c93fb836b6ff783a4738 (patch)
tree91da09e692fc9217a9457b7fb2b1f009fa5108eb
parent1e6c9f709f0bc233f294c938c9ff57f166553557 (diff)
kay/home-assistant: init
-rw-r--r--os/kay/configuration.nix1
-rw-r--r--os/kay/modules/dns/sinanmohd.com.zone3
-rw-r--r--os/kay/modules/home-assistant.nix39
-rw-r--r--os/kay/modules/www.nix10
4 files changed, 52 insertions, 1 deletions
diff --git a/os/kay/configuration.nix b/os/kay/configuration.nix
index 24cd50d..cbcd6a7 100644
--- a/os/kay/configuration.nix
+++ b/os/kay/configuration.nix
@@ -13,6 +13,7 @@
./modules/mail.nix
./modules/dns
./modules/sshfwd.nix
+ ./modules/home-assistant.nix
];
boot.consoleLogLevel = 3;
diff --git a/os/kay/modules/dns/sinanmohd.com.zone b/os/kay/modules/dns/sinanmohd.com.zone
index 0409efc..f3caf8f 100644
--- a/os/kay/modules/dns/sinanmohd.com.zone
+++ b/os/kay/modules/dns/sinanmohd.com.zone
@@ -2,7 +2,7 @@ $ORIGIN sinanmohd.com.
$TTL 2d
@ IN SOA ns1 hostmaster (
- 2024022700 ; serial
+ 2024091105 ; serial
2h ; refresh
5m ; retry
1d ; expire
@@ -40,6 +40,7 @@ www IN CNAME @
git IN CNAME @
bin IN CNAME @
static IN CNAME @
+home IN CNAME @
lia IN A 65.0.3.127
diff --git a/os/kay/modules/home-assistant.nix b/os/kay/modules/home-assistant.nix
new file mode 100644
index 0000000..b611817
--- /dev/null
+++ b/os/kay/modules/home-assistant.nix
@@ -0,0 +1,39 @@
+{ pkgs, ... }: {
+ services.postgresql = {
+ enable = true;
+
+ ensureDatabases = [ "hass" ];
+ ensureUsers = [{
+ name = "hass";
+ ensureDBOwnership = true;
+ }];
+ };
+
+ services.home-assistant = {
+ enable = true;
+ package = (pkgs.home-assistant.override {
+ extraPackages = py: with py; [ psycopg2 ];
+ }).overrideAttrs (oldAttrs: {
+ doInstallCheck = false;
+ });
+
+ extraComponents = [
+ "analytics"
+ "google_translate"
+ "met"
+ "radio_browser"
+ "shopping_list"
+ ];
+
+ config = {
+ default_config = {};
+
+ recorder.db_url = "postgresql://@/hass";
+ http = {
+ server_host = "127.0.0.1";
+ trusted_proxies = [ "127.0.0.1" ];
+ use_x_forwarded_for = true;
+ };
+ };
+ };
+}
diff --git a/os/kay/modules/www.nix b/os/kay/modules/www.nix
index 54eab65..f565cac 100644
--- a/os/kay/modules/www.nix
+++ b/os/kay/modules/www.nix
@@ -87,6 +87,16 @@ in
locations."= /".return = "301 https://www.${domain}";
};
+ "home.${domain}" = defaultOpts // {
+ extraConfig = "proxy_buffering off;";
+ locations."/" = {
+ proxyWebsockets = true;
+ proxyPass = "http://127.0.0.1:${
+ builtins.toString config.services.home-assistant.config.http.server_port
+ }";
+ };
+ };
+
"${fscusat}" = defaultOpts // {
useACMEHost = null;
enableACME = true;