default.nix (2274B) - Raw
1 { 2 config, 3 lib, 4 pkgs, 5 myData, 6 ... 7 }: 8 let 9 cfg = config.mj.services.hass; 10 in 11 { 12 options.mj.services.hass = with lib.types; { 13 enable = lib.mkEnableOption "Enable home-assistant"; 14 }; 15 16 config = lib.mkIf cfg.enable { 17 environment.systemPackages = [ ]; 18 19 services = { 20 mosquitto = { 21 enable = true; 22 listeners = [ 23 { 24 address = "::"; 25 acl = [ "pattern readwrite #" ]; 26 omitPasswordAuth = true; 27 settings.allow_anonymous = true; 28 } 29 ]; 30 }; 31 32 home-assistant = { 33 enable = true; 34 extraComponents = [ 35 "met" 36 "radio_browser" 37 38 # my stuff 39 "yamaha_musiccast" 40 "dlna_dmr" 41 "shelly" 42 "webostv" 43 "daikin" 44 "ipp" 45 "prometheus" 46 "mqtt" 47 ]; 48 customComponents = [ 49 pkgs.home-assistant-custom-components.frigate 50 ]; 51 config = { 52 default_config = { }; 53 54 http = { 55 use_x_forwarded_for = true; 56 trusted_proxies = [ "127.0.0.1" ]; 57 }; 58 homeassistant = { 59 auth_providers = [ 60 { type = "homeassistant"; } 61 { 62 # TODO trust a subset 63 type = "trusted_networks"; 64 trusted_networks = myData.subnets.tailscale.cidr; 65 } 66 ]; 67 }; 68 69 wake_on_lan = { }; 70 71 prometheus = { 72 namespace = "hass"; 73 requires_auth = false; 74 }; 75 76 # requires a restore from backup 77 "automation ui" = "!include automations.yaml"; 78 "automation yaml" = [ 79 { 80 alias = "Turn On Living Room TV with WakeOnLan"; 81 trigger = [ 82 { 83 platform = "webostv.turn_on"; 84 entity_id = "media_player.lg_webos_smart_tv"; 85 } 86 ]; 87 action = [ 88 { 89 service = "wake_on_lan.send_magic_packet"; 90 data = { 91 mac = "74:e6:b8:4c:fb:b7"; 92 }; 93 } 94 ]; 95 } 96 ]; 97 }; 98 }; 99 }; 100 }; 101 }