all repos — nixfiles @ 1232c39655d63f1876c42adfab6e69eb4d69e5ce

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

system/roles/home-automation.nix (view raw)

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
  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
      ## Keep in case of new setup
      # "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}"
  ];
}