❄️ Dotfiles and NixOS configurations
1{
2 config,
3 pkgs,
4 ...
5}: {
6 age.secrets."home-assistant-secrets.yaml" = {
7 file = ../../secrets/eclipse/home-assistant-secrets.yaml.age;
8 owner = "hass";
9 group = "hass";
10 };
11
12 services.home-assistant = {
13 enable = true;
14 extraComponents = [
15 "automation"
16 "co2signal" # Electricity Maps
17 "default_config"
18 "esphome"
19 "forecast_solar"
20 "google_translate"
21 "met"
22 "mobile_app"
23 "mqtt"
24 "shelly"
25 "tuya"
26 "zha"
27 ];
28 customComponents = with pkgs.home-assistant-custom-components; [
29 frigate
30 pkgs.ha-solarman # from local overlay
31 ];
32 config = {
33 homeassistant = {
34 name = "Haus";
35 latitude = "!secret latitude";
36 longitude = "!secret longitude";
37 elevation = "!secret elevation";
38 unit_system = "metric";
39 time_zone = config.time.timeZone;
40 };
41 http = {
42 server_host = "127.0.0.1";
43 server_port = 8123;
44 use_x_forwarded_for = true;
45 trusted_proxies = [
46 "127.0.0.1"
47 ];
48 };
49 default_config = {};
50
51 alarm_control_panel = [
52 {
53 platform = "manual";
54 name = "Alarm";
55 code = "!secret alarm_code";
56 code_arm_required = true;
57 delay_time = 0;
58 arming_time = 20;
59 arming_states = ["armed_away"];
60 }
61 ];
62
63 "automation ui" = "!include automations.yaml";
64 "scene ui" = "!include scenes.yaml";
65 "script ui" = "!include scripts.yaml";
66 };
67 };
68
69 systemd.tmpfiles.settings."10-hass"."/var/lib/hass/secrets.yaml".L.argument = config.age.secrets."home-assistant-secrets.yaml".path;
70
71 services.udev.extraRules = ''
72 SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="c24de8119f78f011948da3e70ba521c7", SYMLINK+="ttyUSB-SONOFF-ZigBee"
73 '';
74
75 services.traefik.dynamic.files."home-assistant".settings.http = {
76 routers.home-assistant = {
77 entryPoints = ["websecure"];
78 service = "home-assistant";
79 rule = "Host(`smart.sefa.cloud`)";
80 };
81 services.home-assistant.loadBalancer.servers = [{url = with config.services.home-assistant.config.http; "http://${server_host}:${toString server_port}";}];
82 };
83}