diff --git a/flake.lock b/flake.lock index 6d8805e..2e51345 100644 --- a/flake.lock +++ b/flake.lock @@ -413,6 +413,7 @@ "nixpkgs-wayland": "nixpkgs-wayland", "simple-nixos-mailserver": "simple-nixos-mailserver", "simple-osd-daemons": "simple-osd-daemons", + "sonoff-lan": "sonoff-lan", "wee-slack": "wee-slack", "weechat-notify-send": "weechat-notify-send", "weechat-scripts": "weechat-scripts", @@ -454,6 +455,22 @@ "type": "github" } }, + "sonoff-lan": { + "flake": false, + "locked": { + "lastModified": 1615813622, + "narHash": "sha256-05KhxvwHm3hya/9uibSggnRjmU1QOxJNzUacfsoYQ64=", + "owner": "AlexxIT", + "repo": "SonoffLAN", + "rev": "412b1b709c5f5de6f1266cf4e6f0b4795a827976", + "type": "github" + }, + "original": { + "owner": "AlexxIT", + "repo": "SonoffLAN", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1610051610, diff --git a/flake.nix b/flake.nix index cc2c6be..f5030f7 100644 --- a/flake.nix +++ b/flake.nix @@ -55,6 +55,10 @@ nix-zsh-completions.url = "github:Ma27/nix-zsh-completions/flakes"; nix-zsh-completions.flake = false; emacs-overlay.url = "github:nix-community/emacs-overlay"; + sonoff-lan = { + url = "github:AlexxIT/SonoffLAN"; + flake = false; + }; }; outputs = { nixpkgs, nix, self, deploy-rs, ... }@inputs: { diff --git a/machines/T420-Laptop/default.nix b/machines/T420-Laptop/default.nix index 5885248..112591e 100644 --- a/machines/T420-Laptop/default.nix +++ b/machines/T420-Laptop/default.nix @@ -10,6 +10,7 @@ nextcloud nginx vsftpd + home-assistant ]; services.logind.lidSwitch = "ignore"; diff --git a/modules/default.nix b/modules/default.nix index 9fa3810..73bf52b 100755 --- a/modules/default.nix +++ b/modules/default.nix @@ -32,6 +32,7 @@ builtins.listToAttrs (builtins.map (path: { ./servers/nextcloud.nix ./servers/nginx.nix ./servers/vsftpd.nix + ./servers/home-assistant.nix ./services.nix ./themes.nix ./virtualisation.nix diff --git a/modules/servers/home-assistant.nix b/modules/servers/home-assistant.nix new file mode 100644 index 0000000..9fc403b --- /dev/null +++ b/modules/servers/home-assistant.nix @@ -0,0 +1,50 @@ +{ config, pkgs, lib, inputs, ... }: { + services.home-assistant = { + enable = true; + package = (pkgs.home-assistant.override { + extraPackages = py: with py; [ aiohttp-cors zeroconf pycrypto ]; + }).overrideAttrs (_: { + tests = []; + doInstallCheck = false; + }); + config = { + homeassistant = { + name = "Home"; + time_zone = "Europe/Moscow"; + latitude = 1; + longitude = 1; + elevation = 1; + unit_system = "metric"; + temperature_unit = "C"; + }; + # Enable the frontend + frontend = { }; + sonoff = { + default_class = "light"; + }; + mobile_app = { }; + }; + }; + systemd.tmpfiles.rules = [ + "C /var/lib/hass/custom_components/sonoff - - - - ${inputs.sonoff-lan}/custom_components/sonoff" + "Z /var/lib/hass 770 hass hass - -" + ]; + services.nginx = { + virtualHosts."hass.balsoft.ru" = { + enableACME = true; + forceSSL = true; + extraConfig = '' + proxy_buffering off; + ''; + locations."/" = { + proxyPass = "http://127.0.0.1:8123"; + proxyWebsockets = true; + extraConfig = '' + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + ''; + }; + }; + }; +}