{ config, lib, pkgs, self, ... }: { imports = [ self.inputs.nixos-hardware.nixosModules.raspberry-pi-4 ./hardware-configuration.nix ../server.nix ]; nixpkgs.hostPlatform = "aarch64-linux"; hardware = { raspberry-pi."4" = { apply-overlays-dtmerge.enable = true; audio.enable = false; fkms-3d.enable = false; xhci.enable = false; }; deviceTree = { enable = true; filter = "*rpi-4-*.dtb"; overlays = [ { name = "audio-off-overlay"; dtsText = '' /dts-v1/; /plugin/; / { compatible = "brcm,bcm2711"; fragment@0 { target = <&vchiq>; __overlay__ { status = "disabled"; }; }; }; ''; } { # Adapted from: https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/hifiberry-digi-pro-overlay.dts # changes: # - modified top-level "compatible" field from bcm2835 to bcm2711 # - s/i2s_clk_consumer/i2s/ (name on bcm2711 platform) name = "hifiberry-digi-pro"; dtsText = '' /dts-v1/; /plugin/; / { compatible = "brcm,bcm2711"; fragment@0 { target = <&i2s>; __overlay__ { status = "okay"; }; }; fragment@1 { target = <&i2c1>; __overlay__ { #address-cells = <1>; #size-cells = <0>; status = "okay"; wm8804@3b { #sound-dai-cells = <0>; compatible = "wlf,wm8804"; reg = <0x3b>; PVDD-supply = <&vdd_3v3_reg>; DVDD-supply = <&vdd_3v3_reg>; status = "okay"; }; }; }; fragment@2 { target = <&sound>; __overlay__ { compatible = "hifiberry,hifiberry-digi"; i2s-controller = <&i2s>; status = "okay"; clock44-gpio = <&gpio 5 0>; clock48-gpio = <&gpio 6 0>; }; }; }; ''; } ]; }; firmware = with pkgs; [ firmwareLinuxNonfree wireless-regdb ]; }; networking.hostId = "731d1660"; security.rtkit.enable = true; services.pipewire = { enable = true; alsa.enable = true; alsa.support32Bit = true; pulse.enable = true; }; age.secrets."files/services/home-assistant/secrets.yaml" = { file = "${self.inputs.secrets}/files/services/home-assistant/secrets.yaml.age"; path = "${config.services.home-assistant.configDir}/secrets.yaml"; owner = "hass"; group = "hass"; }; services.home-assistant = { enable = true; config = { automation = "!include automations.yaml"; backup = { }; binary_sensor = [ ]; default_config = { }; ffmpeg = { }; homeassistant = { name = "Home"; latitude = "!secret latitude"; longitude = "!secret longitude"; country = "GB"; temperature_unit = "C"; time_zone = config.time.timeZone; unit_system = "metric"; auth_providers = [ { type = "trusted_networks"; trusted_networks = [ "100.64.0.0/10" "127.0.0.1" ]; allow_bypass_login = true; } { type = "homeassistant"; } ]; }; logger = { default = "info"; logs = { }; }; lovelace = { }; media_player = [ ]; mobile_app = { }; mqtt = { }; onkyo = { }; open_meteo = { }; recorder = { purge_keep_days = 365; }; scene = "!include scenes.yaml"; sensor = [ ]; system_health = { }; zeroconf = { }; }; extraComponents = [ "air_quality" "airly" "alert" "api" "application_credentials" "asuswrt" "auth" "automation" "backup" "bayesian" "binary_sensor" # "blackbird" "blueprint" "bluetooth" "bluetooth_adapters" "bluetooth_le_tracker" "button" "calendar" "camera" "cast" "cert_expiry" "climate" "co2signal" "color_extractor" "command_line" "compensation" "config" "configurator" "counter" "cover" "cpuspeed" "default_config" "demo" "derivative" "device_automation" "device_sun_light_trigger" "device_tracker" "dhcp" "dlna_dmr" "dlna_dms" "dnsip" "energy" "esphome" "fail2ban" "fan" "feedreader" "ffmpeg" "file" "file_upload" "filesize" "folder" "folder_watcher" "forecast_solar" "frontend" "gdacs" "generic" "generic_hygrostat" "generic_thermostat" "geo_json_events" "geo_location" "geo_rss_events" "github" "group" "hardware" "hdmi_cec" "history" "history_stats" "homeassistant" "homeassistant_alerts" "homekit" "homekit_controller" "html5" "http" "humidifier" "icloud" "image_processing" "image_upload" "input_boolean" "input_button" "input_datetime" "input_number" "input_select" "input_text" "integration" "ios" "jellyfin" "light" "local_calendar" "local_file" "local_ip" "local_todo" "lock" "logbook" "logentries" "logger" "lovelace" "manual" "manual_mqtt" "matter" "media_player" "media_source" "min_max" "mjpeg" "mobile_app" "modern_forms" "mold_indicator" "moon" "mqtt" "mqtt_eventstream" "mqtt_json" "mqtt_room" "mqtt_statestream" "mysensors" "network" "nmap_tracker" "notify" "number" "onboarding" "onkyo" "panel_custom" "persistent_notification" "person" "ping" "plant" "prometheus" "proximity" "push" "proximity" "python_script" "radio_browser" "random" "recorder" "remote" "repairs" "rest" "rest_command" "rss_feed_template" "scene" "schedule" "scrape" "script" "search" "season" "select" "sense" "sensor" "sensorpush" "shell_command" "shopping_list" "siren" "smtp" "snmp" "sql" "ssdp" "statistics" "stream" "sun" "switch" "switch_as_x" "system_health" "system_log" "systemmonitor" "tag" "tailscale" "tcp" "template" "text" "thread" "threshold" "time_date" "timer" "tod" "todo" "tomorrowio" "trend" "universal" "upb" "update" "upnp" "uptime" "usb" "utility_meter" "vacuum" "vlc" "vlc_telnet" "wake_on_lan" "water_heater" "weather" "webhook" "websocket_api" "wled" "workday" "worldclock" "zeroconf" "zone" ]; customLovelaceModules = with pkgs.home-assistant-custom-lovelace-modules; [ mushroom ]; }; services.mosquitto = { enable = true; listeners = [{ acl = [ "pattern readwrite #" ]; omitPasswordAuth = true; port = 1883; settings = { allow_anonymous = true; }; }]; }; age.secrets."files/services/zigbee2mqtt/secret.yaml" = { file = "${self.inputs.secrets}/files/services/zigbee2mqtt/secret.yaml.age"; path = "${config.services.zigbee2mqtt.dataDir}/secret.yaml"; owner = "zigbee2mqtt"; group = "zigbee2mqtt"; }; services.zigbee2mqtt = { package = pkgs.unstable.zigbee2mqtt; enable = true; dataDir = "/var/lib/zigbee2mqtt"; settings = { homeassistant = lib.optionalAttrs config.services.home-assistant.enable { discovery_topic = "homeassistant"; status_topic = "hass/status"; legacy_entity_attributes = true; legacy_triggers = true; }; availability = true; frontend = true; device_options = { retain = true; }; serial = { port = "/dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0"; }; advanced = { channel = 20; network_key = "!secret.yaml network_key"; pan_id = 13001; ext_pan_id = [ 79 1 73 47 250 136 124 222 ]; transmit_power = 20; }; mqtt = { version = 5; server = "mqtt://localhost:1883"; }; }; }; modules = { networking = { wireless = { enable = true; interfaces = [ "wlan0" ]; }; }; services = { borgmatic = { enable = true; directories = [ "/var/lib/mosquitto" "/var/lib/zigbee2mqtt" ]; repoPath = "ssh://qcw86s11@qcw86s11.repo.borgbase.com/./repo"; }; }; }; # Connection to ONKYO HT-R990 networking.interfaces.end0 = { ipv4.addresses = [{ address = "172.16.0.1"; prefixLength = 30; }]; }; environment.systemPackages = with pkgs; [ python311Packages.onkyo-eiscp libraspberrypi raspberrypi-eeprom ]; system.stateVersion = "22.11"; }