From 639ce36cb08b8836daf7dcfb85d2f30b09b7b071 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Mon, 12 Jan 2026 15:13:02 -0600 Subject: [PATCH] otbr --- flake.lock | 17 ++++++++ .../homeassistant/services/thread/default.nix | 12 ++++-- systems/x86_64-linux/nuc-nixos/default.nix | 41 +++++++++++-------- 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index a10d00c..7f8ce2b 100644 --- a/flake.lock +++ b/flake.lock @@ -1086,6 +1086,22 @@ "type": "github" } }, + "nixpkgs-otbr": { + "locked": { + "lastModified": 1766776257, + "narHash": "sha256-MG9DnzBn6TdAztaMPVhW9sjYj2bi9Jcux0F0fJ6LeO4=", + "owner": "mrene", + "repo": "nixpkgs", + "rev": "0c4c97066d555b7d27a0a56ee400130ec51f02ee", + "type": "github" + }, + "original": { + "owner": "mrene", + "ref": "openthread-border-router", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1751048012, @@ -1472,6 +1488,7 @@ "nixos-hardware": "nixos-hardware", "nixos-raspberrypi": "nixos-raspberrypi", "nixpkgs": "nixpkgs_12", + "nixpkgs-otbr": "nixpkgs-otbr", "nixpkgs-stable": "nixpkgs-stable_2", "nixpkgs-unstable": "nixpkgs-unstable", "pre-commit-hooks-nix": "pre-commit-hooks-nix", diff --git a/modules/nixos/homeassistant/services/thread/default.nix b/modules/nixos/homeassistant/services/thread/default.nix index 98647af..7d48338 100644 --- a/modules/nixos/homeassistant/services/thread/default.nix +++ b/modules/nixos/homeassistant/services/thread/default.nix @@ -1,19 +1,25 @@ -{ config, lib, ... }: +{ inputs, config, namespace, lib, pkgs, ... }: let + inherit (lib.${namespace}) mkModule mkOpt mkBoolOpt; name = "otbr"; cfg = config.${namespace}.services.${name}; + otbrPackage = pkgs.callPackage "${inputs.nixpkgs-otbr}/pkgs/by-name/op/openthread-border-router/package.nix" { }; + otbrConfig = lib.${namespace}.mkModule { inherit config name; description = "Openthread border router"; - options = { }; + options = { + restPort = mkOpt lib.types.int 8081 ""; + }; moduleConfig = { services.openthread-border-router = { enable = true; backboneInterface = "enp2s0"; + package = otbrPackage; rest = { listenAddress = cfg.listenAddress; - listenPort = cfg.port; + listenPort = cfg.restPort; }; web = { listenAddress = cfg.listenAddress; diff --git a/systems/x86_64-linux/nuc-nixos/default.nix b/systems/x86_64-linux/nuc-nixos/default.nix index a6387e6..9686196 100644 --- a/systems/x86_64-linux/nuc-nixos/default.nix +++ b/systems/x86_64-linux/nuc-nixos/default.nix @@ -53,8 +53,8 @@ firewall = { enable = true; allowPing = true; - allowedTCPPorts = [ 8192 ]; - allowedUDPPorts = [ 8192 ]; + allowedTCPPorts = [ 8192 8080 8081 ]; + allowedUDPPorts = [ 8192 8080 8081 ]; }; }; @@ -68,24 +68,31 @@ # # Services # # # ################################################### - services.home-assistant = { - enable = true; - automation = { - lightswitch = { - living-room-lights = { - id = 1741726347213; - alias = "Living Room Light Switch"; - mqttDeviceId = "958ff6b3c9df0db21e418aaf6410b996"; - lightEntityId = "light.living_room_lights"; - }; - bedroom-lights = { - id = 1741726231261; - alias = "Bedroom Light Switch"; - mqttDeviceId = "de0f34498214842dcccaa6b08967d6b5"; - lightEntityId = "light.bedroom_lights"; + services = { + home-assistant = { + enable = true; + automation = { + lightswitch = { + living-room-lights = { + id = 1741726347213; + alias = "Living Room Light Switch"; + mqttDeviceId = "958ff6b3c9df0db21e418aaf6410b996"; + lightEntityId = "light.living_room_lights"; + }; + bedroom-lights = { + id = 1741726231261; + alias = "Bedroom Light Switch"; + mqttDeviceId = "de0f34498214842dcccaa6b08967d6b5"; + lightEntityId = "light.bedroom_lights"; + }; }; }; }; + otbr = { + enable = true; + restPort = 8081; + port = 8080; + }; }; # ###################################################