btw i use nix
1{
2 config,
3 pkgs,
4 lib,
5 nixos-hardware,
6 nixpkgs,
7 ...
8}:
9
10{
11 imports = [
12 ./hardware-configuration.nix
13 "${nixos-hardware}/raspberry-pi/4"
14 ];
15
16 custom = {
17 enable = true;
18 tailscale = true;
19 autoUpgrade.enable = true;
20 homeManager.enable = true;
21 };
22
23 home-manager.users.${config.custom.username}.config.custom.machineColour = "red";
24
25 networking.networkmanager.enable = true;
26
27 services.journald.extraConfig = ''
28 SystemMaxUse=4G
29 '';
30
31 services.caddy = {
32 enable = true;
33 virtualHosts."http://shrew" = {
34 listenAddresses = [ "100.64.0.6" ];
35 extraConfig = "reverse_proxy http://127.0.0.1:15606";
36 };
37 };
38
39 environment.systemPackages = with pkgs; [ mosquitto ];
40
41 services.zigbee2mqtt = {
42 enable = true;
43 settings = {
44 mqtt = {
45 server = "mqtt://shrew:1883";
46 user = "zigbee2mqtt";
47 password = "test";
48 };
49 serial = {
50 port = "/dev/ttyUSB0";
51 };
52 frontend = {
53 port = 15606;
54 url = "http://shrew";
55 };
56 homeassistant = true;
57 advanced = {
58 channel = 15;
59 };
60 };
61 };
62
63 services.mosquitto = {
64 enable = true;
65 listeners = [
66 {
67 users = {
68 zigbee2mqtt = {
69 acl = [ "readwrite #" ];
70 hashedPassword = "$6$nuDIW/ZPVsrDHyBe$JffJJvvMG+nH8GH9V5h4FqJkU0nfiFkDzAsdYNTHeJMgBXEX9epPkQTUdLG9L47K54vMxm/+toeMAiKD63Dfkw==";
71 };
72 homeassistant = {
73 acl = [ "readwrite #" ];
74 hashedPassword = "$7$101$wGQZPdVdeW7iQFmH$bK/VOR6LXCLJKbb6M4PNeVptocjBAWXCLMtEU5fQNBr0Y5UAWlhVg8UAu4IkIXgnViI51NnhXKykdlWF63VkVQ==";
75 };
76 };
77 }
78 ];
79 };
80
81 services.home-assistant = {
82 enable = true;
83 extraComponents = [
84 "default_config"
85 "esphome"
86 "met"
87 "rpi_power"
88 "radio_browser"
89 "mqtt"
90 "zha"
91 "stt"
92 "tts"
93 "whisper"
94 "piper"
95 "wyoming"
96 "wake_word"
97 "google_assistant"
98 "google_translate"
99 ];
100 customComponents = with pkgs.overlay-unstable.home-assistant-custom-components; [
101 adaptive_lighting
102 ];
103 config = {
104 # Includes dependencies for a basic setup
105 # https://www.home-assistant.io/integrations/default_config/
106 default_config = { };
107 automation = "!include automations.yaml";
108 scene = "!include scenes.yaml";
109 http = {
110 use_x_forwarded_for = true;
111 trusted_proxies = [ "100.64.0.2" ];
112 };
113 google_assistant = {
114 project_id = "shrew-25325";
115 service_account = "!include SERVICE_ACCOUNT.JSON";
116 report_state = true;
117 exposed_domains = [
118 "switch"
119 "light"
120 ];
121 entity_config = {
122 "light.room_bed_left" = {
123 name = "BED_LEFT";
124 aliases = [ "LEFT" ];
125 room = "Bedroom";
126 };
127 "switch.room_bed_right" = {
128 name = "BED_RIGHT";
129 aliases = [ "RIGHT" ];
130 room = "Bedroom";
131 };
132 "light.room_ceil" = {
133 name = "CEIL";
134 aliases = [ "CEILING" ];
135 room = "Bedroom";
136 };
137 "light.room_strip" = {
138 name = "STRIP";
139 room = "Bedroom";
140 };
141 "switch.fan" = {
142 name = "FAN";
143 room = "Bedroom";
144 };
145 };
146 };
147 adaptive_lighting = {
148 sunrise_time = "06:00:00";
149 sunset_time = "18:00:00";
150 lights = [
151 "light.bed_left"
152 "light.bed_right"
153 "light.ceiling"
154 "light.strip"
155 ];
156 };
157 };
158 };
159
160 #services.wyoming = {
161 # faster-whisper.servers.en = {
162 # enable = true;
163 # language = "en";
164 # uri = "tcp://0.0.0.0:10300";
165 # };
166 # piper.servers.en = {
167 # enable = true;
168 # voice = "en_GB-alba-medium";
169 # uri = "tcp://0.0.0.0:10200";
170 # };
171 # openwakeword = {
172 # enable = true;
173 # uri = "tcp://0.0.0.0:10400";
174 # };
175 #};
176
177 age.secrets.restic-shrew.file = ../../secrets/restic-shrew.age;
178 services.restic.backups.${config.networking.hostName} = {
179 repository = "rest:http://100.64.0.9:8000/${config.networking.hostName}/";
180 passwordFile = config.age.secrets.restic-shrew.path;
181 initialize = true;
182 paths = [ "/var/lib/hass" ];
183 timerConfig = {
184 OnCalendar = "03:00";
185 randomizedDelaySec = "1hr";
186 };
187 };
188}