summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/shack/glados/default.nix
blob: e8ed18f0d566a801e413dac00016cd5c1117685e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ config, pkgs, lib, ... }:
let
  kodi-host = "192.168.8.11";
  confdir = "/var/lib/homeassistant-docker";
in {
  imports = [ ./zigbee.nix ];

  networking.firewall.allowedTCPPorts = [ 8123 ];
  virtualisation.oci-containers.containers.hass = {
    image = "homeassistant/home-assistant:latest";
    environment = {
      TZ = "Europe/Berlin";
      UMASK = "007";
    };
    extraOptions = ["--net=host" "--device=/dev/zigbee" ];
    volumes = [
      "${confdir}:/config"
      "${./zigbee-quirks}:/quirks"
      #"${confdir}/docker-run:/etc/services.d/home-assistant/run:"
    ];
  };
  systemd.tmpfiles.rules = [
    #"f ${confdir}/docker-run 0770 kiosk kiosk - -"
    # TODO:
    "d ${confdir} 0770 root root - -"
  ];

  services.nginx.virtualHosts."hass.shack" = {
    serverAliases = [ "glados.shack" ];
    locations."/" = {
      proxyPass = "http://localhost:8123";
      extraConfig = ''
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host             $host;
          proxy_set_header X-Real-IP        $remote_addr;

          proxy_buffering off;
        '';
    };
  };
}