diff --git a/flake.lock b/flake.lock index 1dab8b7..ed6ff21 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1648942457, - "narHash": "sha256-i29Z1t3sVfCNfpp+KAfeExvpqHQSbLO1KWylTtfradU=", + "lastModified": 1652712410, + "narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=", "owner": "ryantm", "repo": "agenix", - "rev": "0d5e59ed645e4c7b60174bc6f6aac6a203dc0b01", + "rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b", "type": "github" }, "original": { @@ -25,11 +25,11 @@ ] }, "locked": { - "lastModified": 1649887911, - "narHash": "sha256-Af0Ppb1RZ7HWuxUvF0/O7h3cy8tqU2eKFyVwyA1ZD+w=", + "lastModified": 1651519540, + "narHash": "sha256-3k6p8VsTwwRPQjE8rrMh+o2AZACZn/eeYJ7ivdQ/Iro=", "owner": "nix-community", "repo": "home-manager", - "rev": "7244c6715cb8f741f3b3e1220a9279e97b2ed8f5", + "rev": "d93d56ab8c1c6aa575854a79b9d2f69d491db7d0", "type": "github" }, "original": { @@ -57,11 +57,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1650244918, - "narHash": "sha256-DsS5nxjTpnoUC4pNXJI1rit7TnDTij8vQDa5PtcDCD0=", + "lastModified": 1652881001, + "narHash": "sha256-k9JmPCojaJnqGz4aRXXT1HZqJKHCXijoMfBAb24abXk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7b38b03d76ab71bdc8dc325e3f6338d984cc35ca", + "rev": "2d474d6a4a43a0348b78db68dc00c491032cf5cf", "type": "github" }, "original": { @@ -73,11 +73,11 @@ }, "nixunstable": { "locked": { - "lastModified": 1651007983, - "narHash": "sha256-GNay7yDPtLcRcKCNHldug85AhAvBpTtPEJWSSDYBw8U=", + "lastModified": 1652794215, + "narHash": "sha256-erVj41IcCPDWdt8CwT60ygD+SY/uhqip3RXwiESOCVk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e10da1c7f542515b609f8dfbcf788f3d85b14936", + "rev": "242efdc5a5aff8222c1152c0e4b9262bd02915b6", "type": "github" }, "original": { @@ -89,11 +89,11 @@ }, "nur": { "locked": { - "lastModified": 1651053120, - "narHash": "sha256-PKbB7MK6jwG4G3A/2RR0ZA8YSNanwi5R+Bvv/LwzKwo=", + "lastModified": 1652997257, + "narHash": "sha256-vF4ji8t3ZgwjhGH0nrlO1n4AhsOfL7H4eGSP10BKj/k=", "owner": "nix-community", "repo": "NUR", - "rev": "2eb8999947487d915d6a1100d672284a1989c905", + "rev": "4ab0b3bc0bcfa401360cac1f77a4355589c465f7", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 77a65e6..3184c3a 100644 --- a/flake.nix +++ b/flake.nix @@ -41,9 +41,21 @@ modules = mods name; }; + unstableMachine = system: name: inputs.nixunstable.lib.nixosSystem { + system = system; + modules = mods name; + specialArgs = { + nixpkgs = inputs.nixunstable; + nixunstable = inputs.nixunstable; + agenix = inputs.agenix; + home-manager = inputs.home-manager; + nur = inputs.nur; + }; + }; + in { nixosConfigurations = { - "2maccabees" = machine "aarch64-linux" "2maccabees"; + "2maccabees" = unstableMachine "aarch64-linux" "2maccabees"; "linode" = machine "x86_64-linux" "linode"; diff --git a/hosts/2maccabees/home-assistant.nix b/hosts/2maccabees/home-assistant.nix index ac77178..e921121 100755 --- a/hosts/2maccabees/home-assistant.nix +++ b/hosts/2maccabees/home-assistant.nix @@ -7,19 +7,44 @@ in { virtualisation.podman.enable = true; + services.home-assistant = { + enable = true; + configDir = "/var/lib/hass"; + package = (pkgs.home-assistant.override { + extraComponents = [ + "accuweather" + "cast" + "eufy" + "lovelace" + "tplink" + "wiz" + "zwave_js" + ]; + }).overrideAttrs (oldAttrs: { + doInstallCheck = false; + }); + + config = { + default_config = {}; + esphome = {}; # Get these things loaded, even if not configured + met = {}; + tts = [ { platform = "google_translate"; } ]; + http = { + use_x_forwarded_for = true; + trusted_proxies = [ "127.0.0.1" "::1" ]; + server_host = "127.0.0.1"; + }; + "automation ui" = "!include automations.yaml"; + "script ui" = "!include scripts.yaml"; + "scene ui" = "!include scenes.yaml"; + }; + }; + # Although NixOS has a package for Home Assistant, it is not kept as up to date as the container and the upstream # is very vocal about only supporting their own container or the HAOS deployments. So we deploy the container here # and avoid any potential messes from that virtualisation.oci-containers = { backend = "podman"; - containers."home-assistant" = { - image = "ghcr.io/home-assistant/home-assistant:stable"; - ports = [ "127.0.0.1:8123:8123" ]; - volumes = [ "/var/lib/hass:/config" ]; - extraOptions = [ - "--device" "/dev/ttyAMA0" - ]; - }; # I have ZWave devices. The easiest way to connect to them is the zwavejs2mqtt service running, so we spin up # its container and map the ZWave device into it @@ -36,13 +61,6 @@ in # Both of the above container need storage for their configuration and devices, but it is not created correctly by # the container. So we add the creation of /var/lib/{zwave,hass} to the systemd Unit files systemd.services = { - "podman-home-assistant" = { - serviceConfig = { - StateDirectory = "hass"; - StateDirectoryMode = pkgs.lib.mkForce "0777"; - }; - }; - "podman-zwave".serviceConfig = { StateDirectory = "zwave"; StateDirectoryMode = pkgs.lib.mkForce "0777"; @@ -50,49 +68,6 @@ in }; - # Podman 3.4, which is in NixOS 21.11 does not support creating multiple network interfaces during launch. Starting in Podman - # 4.0 (NixOS 22.05) that will be possible. For now, adding this sidecar service that executes after every time the Home Assistant - # container is started will do the necessary Podman commands to attach the container to the interface for VLAN 66. Once we - # upgrade to NixOS 22.05 this service can go away and we can explicitly add two "--network" options to the Home Assistant container - systemd.services."home-assistant-network-attach" = { - requires = service_list; - path = [ pkgs.podman pkgs.coreutils ]; - script = "sleep 10 && podman network connect podman66 home-assistant"; - wantedBy = service_list; - serviceConfig = { - Type = "oneshot"; - }; - }; - - # This ensures that Podman has a separate network configured to attach to my IOT VLAN so that Home Assistant is able to communicate - # with my devices as well as with the rest of the LAN. - systemd.services.podman66 = { - wantedBy = service_list; - before = service_list; - path = [ pkgs.podman ]; - script = "podman network create -d macvlan -o parent=vlan66 --subnet 192.168.66.0/24 --ip-range 192.168.66.192/26 --gateway 192.168.66.1 podman66 || true"; - serviceConfig = { - Type = "oneshot"; - }; - }; - - # I do not want to have to remember the port number for Home Assistant's UI, so we use Nginx to proxy communication from - # smart.thehellings.lan to the Home Assistant UI - # After the first activation of this container, before you can access the Home Assistant UI, you need to ensure that the - # Home Assistant's configuration at /var/lib/hass/configuration.yaml includes the following option. Update the IP address - # if you have changed the value of your default podman network. - # ```yaml - # http: - # use_x_forwarded_for: true - # trusted_proxies: - # - "10.88.0.1" - # ``` - # Home assistant will not accept connections from the proxy if these values are not set. If you are adding those values - # manually after initial creation of the containers, then you will need to issue `systemctl restart podman-home-assistant.service` - # for Home Assistant to pick up the new values. After that, proxy connections should work well. If you are sitting behind - # multiple layers of proxies, then add more of them in the list. The list also accepts subnet notation in case you have - # multiple potentially incoming connections. So you could do "10.88.0.1/24", according to the docs. However, that has not - # worked in my testing, as Home Assistant throws an error on start up saying that value is invalid greg.proxies."smart.thehellings.lan".target = "http://127.0.0.1:8123"; # Ensure that both ports are up and running. We keep 8123 directly open because we are on the LAN and sometimes want to connect @@ -107,12 +82,6 @@ in services.syncthing = { enable = true; folders = { - "asdf-fdsa" = { - enable = true; - path = "/var/lib/hass"; - devices = [ "nas" ]; - }; - "zwave-live" = { enable = true; path = "/var/lib/zwave";