diff options
author | Ethel Morgan <eth@ethulhu.co.uk> | 2020-06-24 15:10:19 +0100 |
---|---|---|
committer | Ethel Morgan <eth@ethulhu.co.uk> | 2020-06-24 15:10:19 +0100 |
commit | cd73eb2b63d1049f7ddfb28fc45e2a4595f34d38 (patch) | |
tree | 7d5a09c89cb10c611d9b29dbcbd4c02637d457c3 /nixos/modules/services/catbus-actuator-wakeonlan.nix | |
parent | ea950b8c4cf72034e4f000aee58be6b9b5d489d0 (diff) |
use types.attrsOf for option sets for some daemons
Diffstat (limited to 'nixos/modules/services/catbus-actuator-wakeonlan.nix')
-rw-r--r-- | nixos/modules/services/catbus-actuator-wakeonlan.nix | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/nixos/modules/services/catbus-actuator-wakeonlan.nix b/nixos/modules/services/catbus-actuator-wakeonlan.nix index 0187706..84839e6 100644 --- a/nixos/modules/services/catbus-actuator-wakeonlan.nix +++ b/nixos/modules/services/catbus-actuator-wakeonlan.nix @@ -5,18 +5,10 @@ let cfg = config.eth.services.catbus-actuator-wakeonlan; - 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 { @@ -37,20 +29,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"; - }; - topic = mkOption { - type = types.str; - description = "MQTT topic for controlling the device"; - example = "home/house/speakers/power"; + 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"; + }; }; - }; + }); + 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."; }; }; |