summaryrefslogtreecommitdiff
path: root/nixos/modules/services/catbus-observer-networkpresence.nix
diff options
context:
space:
mode:
authorEthel Morgan <eth@ethulhu.co.uk>2020-06-24 15:10:19 +0100
committerEthel Morgan <eth@ethulhu.co.uk>2020-06-24 15:10:19 +0100
commitcd73eb2b63d1049f7ddfb28fc45e2a4595f34d38 (patch)
tree7d5a09c89cb10c611d9b29dbcbd4c02637d457c3 /nixos/modules/services/catbus-observer-networkpresence.nix
parentea950b8c4cf72034e4f000aee58be6b9b5d489d0 (diff)
use types.attrsOf for option sets for some daemons
Diffstat (limited to 'nixos/modules/services/catbus-observer-networkpresence.nix')
-rw-r--r--nixos/modules/services/catbus-observer-networkpresence.nix45
1 files changed, 20 insertions, 25 deletions
diff --git a/nixos/modules/services/catbus-observer-networkpresence.nix b/nixos/modules/services/catbus-observer-networkpresence.nix
index be48e27..528ab66 100644
--- a/nixos/modules/services/catbus-observer-networkpresence.nix
+++ b/nixos/modules/services/catbus-observer-networkpresence.nix
@@ -5,18 +5,10 @@ let
cfg = config.eth.services.catbus-observer-networkpresence;
- configJSON = pkgs.writeText "config.json" ''
- {
- "mqttBroker": "tcp://${cfg.mqttBroker.host}:${toString cfg.mqttBroker.port}",
-
- "devices": {
- "TV": {
- "mac": "${cfg.devices.tv.mac}",
- "topic": "${cfg.devices.tv.topic}"
- }
- }
- }
- '';
+ configJSON = pkgs.writeText "config.json" (builtins.toJSON {
+ mqttBroker = "tcp://${cfg.mqttBroker.host}:${toString cfg.mqttBroker.port}";
+ devices = cfg.devices;
+ });
in {
@@ -44,20 +36,23 @@ in {
};
};
- # TODO: replace this with a proper set of option sets.
- devices = {
- tv = {
- mac = mkOption {
- type = types.str;
- description = "The device's MAC address";
- example = "aa:bb:cc:dd:ee:ff";
+ devices = mkOption {
+ type = types.attrsOf (types.submodule {
+ options = {
+ mac = mkOption {
+ type = types.str;
+ description = "The device's MAC address";
+ example = "aa:bb:cc:dd:ee:ff";
+ };
+ topic = mkOption {
+ type = types.str;
+ description = "MQTT topic for controlling the device";
+ example = "home/house/speakers/power";
+ };
};
- topic = mkOption {
- type = types.str;
- description = "MQTT topic for controlling the device";
- example = "home/house/speakers/power";
- };
- };
+ });
+ example = { TV = { mac = "aa:bb:cc:dd:ee:ff"; topic = "home/living-room/tv/power"; }; };
+ description = "A set of devices and their MACs & controller topics.";
};
};