1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.usbrelayd;
9in
10{
11 options.services.usbrelayd = with lib.types; {
12 enable = lib.mkEnableOption "USB Relay MQTT daemon";
13
14 broker = lib.mkOption {
15 type = str;
16 description = "Hostname or IP address of your MQTT Broker.";
17 default = "127.0.0.1";
18 example = [
19 "mqtt"
20 "192.168.1.1"
21 ];
22 };
23
24 clientName = lib.mkOption {
25 type = str;
26 description = "Name, your client connects as.";
27 default = "MyUSBRelay";
28 };
29 };
30
31 config = lib.mkIf cfg.enable {
32
33 environment.etc."usbrelayd.conf".text = ''
34 [MQTT]
35 BROKER = ${cfg.broker}
36 CLIENTNAME = ${cfg.clientName}
37 '';
38
39 services.udev.packages = [ pkgs.usbrelayd ];
40 systemd.packages = [ pkgs.usbrelayd ];
41 users.groups.usbrelay = { };
42 };
43
44 meta = {
45 maintainers = with lib.maintainers; [ wentasah ];
46 };
47}